This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
libtf:documentation:api:persistentobject [2018/02/24 18:35] – lee | libtf:documentation:api:persistentobject [2018/09/24 17:15] (current) – removed lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[libtf: | ||
- | |||
- | |||
- | ====== LibTF.PersistentObject ====== | ||
- | |||
- | Blurb. | ||
- | |||
- | |||
- | ===== Fields ===== | ||
- | |||
- | ==== (PersistentObject).id ==== | ||
- | |||
- | * Getter: Returns the persistence id of this object. | ||
- | * Setter: None. | ||
- | |||
- | |||
- | ==== (PersistentObject).parentId ==== | ||
- | |||
- | * Getter: Returns the persistence id of this object' | ||
- | * Setter: None. | ||
- | |||
- | |||
- | ==== (PersistentObject).parent ==== | ||
- | |||
- | * Getter: Returns fully instantiated parent of this object. | ||
- | * Setter: None. | ||
- | |||
- | |||
- | ===== Methods ===== | ||
- | |||
- | ==== (PersistentObject).hasPersistent( subid ) ==== | ||
- | |||
- | * //subid// is a persistence id fragment referring to some child data record for this object. | ||
- | * Returns: True if there is a record for the specified child data on this object, or False if there is not. | ||
- | * Throws: Error if: subid contains invalid characters. | ||
- | |||
- | Checks to see if there is child data available for this object. | ||
- | |||
- | This method is generally only used internally by derived classes. | ||
- | |||
- | < | ||
- | if( tfGet(" | ||
- | alert( "Joe has a femininity child field!" | ||
- | </ | ||
- | |||
- | | ||
- | this.= function( subid ) | ||
- | { | ||
- | if( subid == null ) | ||
- | throw "Null id!"; | ||
- | return Persistence.has( id+" | ||
- | } | ||
- | |||
- | this.getPersistent = function( subid ) | ||
- | { | ||
- | if( subid == null ) | ||
- | throw "Null id!"; | ||
- | if( this.hasPersistent(subid) ) | ||
- | return Persistence.get( id+" | ||
- | return null; | ||
- | } | ||
- | |||
- | this.setPersistent = function( subid, value ) | ||
- | { | ||
- | if( subid == null ) | ||
- | throw "Null id!"; | ||
- | return Persistence.set( id+" | ||
- | } | ||
- | |||
- | this.resetPersistent = function( subid ) | ||
- | { | ||
- | if( subid == null ) | ||
- | throw "Null id!"; | ||
- | return Persistence.reset( id+" | ||
- | } | ||
- | | ||
- | this.getName = function() | ||
- | { | ||
- | if( this.hasPersistent(" | ||
- | return this.getPersistent(" | ||
- | return null; | ||
- | } | ||
- | | ||
- | this.getAName = function() | ||
- | { | ||
- | var name = this.getName(); | ||
- | if( this.getPersistent(" | ||
- | return name; | ||
- | if( this.hasPersistent(" | ||
- | return this.getPersistent(" | ||
- | switch( name.charAt(0) ) | ||
- | { | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | case ' | ||
- | return "an " + name; | ||
- | default: | ||
- | return "a " + name; | ||
- | } | ||
- | } | ||
- | |||
- | [[libtf: | ||
- | |||