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 19:38] – 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. | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).name ==== | ||
| - | |||
| - | * Getter: Returns the object' | ||
| - | * Setter: Sets the object' | ||
| - | |||
| - | The display name of the object, without any article. | ||
| - | |||
| - | <code javascript> | ||
| - | var someDude = tfGet(" | ||
| - | alert( " | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).aName ==== | ||
| - | |||
| - | * Getter: Returns the object' | ||
| - | * Setter: None. | ||
| - | |||
| - | The display name of the object, with the correct article. | ||
| - | |||
| - | If the first character of the //.name// field is capitalized, | ||
| - | |||
| - | If the first character of the //.name// field is a vowel, the " | ||
| - | |||
| - | Otherwise, the " | ||
| - | |||
| - | These rules do not always work. For example, "an honorable man" or "a European swallow" | ||
| - | |||
| - | <code javascript> | ||
| - | alert( "You are carrying " + tfGet(" | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).nameIsProper ==== | ||
| - | |||
| - | Set this field to True to suppress the printing of an article in the //.aName// field. | ||
| - | |||
| - | // | ||
| - | |||
| - | <code javascript> | ||
| - | var book = tfGet(" | ||
| - | // book.name is " | ||
| - | // With the " being the first character, it won't be recognized as proper. | ||
| - | // So .aName will return: a "Atlas Shrugged" | ||
| - | book.nameIsProper = true; | ||
| - | // Now .aName will properly return just: "Atlas Shrugged" | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).nameIrregularArticle ==== | ||
| - | |||
| - | Set this field to override the default article choice in //.aName//. | ||
| - | |||
| - | // | ||
| - | |||
| - | <code javascript> | ||
| - | tfGet(" | ||
| - | tfGet(" | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== 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 for the given //subid// available for this object. | ||
| - | |||
| - | //This method is generally only used internally by derived classes. | ||
| - | |||
| - | <code javascript> | ||
| - | if( tfGet(" | ||
| - | alert( "Joe has a lastName child field!" | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).getPersistent( subid ) ==== | ||
| - | |||
| - | * //subid// is a persistence id fragment referring to some child data record for this object. | ||
| - | * Returns: The specified child data from this object, or null if there is none. | ||
| - | * Throws: Error if: subid contains invalid characters. | ||
| - | |||
| - | Returns the child data for the given //subid// on this object. | ||
| - | |||
| - | //This method is generally only used internally by derived classes. | ||
| - | |||
| - | <code javascript> | ||
| - | alert( " | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).setPersistent( subid, value ) ==== | ||
| - | |||
| - | * //subid// is a persistence id fragment referring to some child data record for this object. | ||
| - | * //value// is what to set that child data to. | ||
| - | * Returns: Nothing, but that is a bug and it ought to return the previous value. | ||
| - | * Throws: Error if: subid contains invalid characters. | ||
| - | |||
| - | Sets the child data for the given //subid// on this object to //value//. | ||
| - | |||
| - | //This method is generally only used internally by derived classes. | ||
| - | |||
| - | <code javascript> | ||
| - | tfGet(" | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== (PersistentObject).resetPersistent( subid ) ==== | ||
| - | |||
| - | * //subid// is a persistence id fragment referring to some child data record for this object. | ||
| - | * Returns: the previous value (before reset). | ||
| - | * Throws: Error if: subid contains invalid characters. | ||
| - | |||
| - | Resets the child data for the given //subid// on this object to whatever was defined in Persistence.setDefaults(). | ||
| - | |||
| - | //This method is generally only used internally by derived classes. | ||
| - | |||
| - | <code javascript> | ||
| - | tfGet(" | ||
| - | </ | ||
| - | |||
| - | |||
| - | [[libtf: | ||