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:53] – lee | libtf:documentation:api:persistentobject [2018/09/24 17:15] (current) – removed lee | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[libtf: | ||
- | |||
- | |||
- | ====== LibTF.PersistentObject ====== | ||
- | |||
- | Blurb. | ||
- | |||
- | |||
- | ===== Fields ===== | ||
- | |||
- | ==== (PersistentObject).id ==== | ||
- | |||
- | * Access: Read-Only. | ||
- | * Type: String. | ||
- | |||
- | The persistence id of the object. | ||
- | |||
- | |||
- | ==== (PersistentObject).parentId ==== | ||
- | |||
- | * Access: Read-Only. | ||
- | * Type: String. | ||
- | |||
- | The persistence id of the object' | ||
- | |||
- | |||
- | ==== (PersistentObject).parent ==== | ||
- | |||
- | * Access: Read-Only. | ||
- | * Type: A PersistentObject, | ||
- | |||
- | The fully instantiated parent of this object. | ||
- | |||
- | |||
- | ==== (PersistentObject).name ==== | ||
- | |||
- | * Access: Read-Write. | ||
- | * Type: String. | ||
- | |||
- | The display name of the object, without any article. | ||
- | |||
- | <code javascript> | ||
- | var someDude = tfGet(" | ||
- | alert( " | ||
- | </ | ||
- | |||
- | |||
- | ==== (PersistentObject).aName ==== | ||
- | |||
- | * Access: Read-Only. | ||
- | * Type: String. | ||
- | |||
- | The display name of the object, with the correct article prepended. | ||
- | |||
- | 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 ==== | ||
- | |||
- | * Access: Read-Write. | ||
- | * Type: Boolean. | ||
- | |||
- | 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 ==== | ||
- | |||
- | * Access: Read-Write. | ||
- | * Type: String. | ||
- | |||
- | Set this field to override the default article choice in // | ||
- | |||
- | // | ||
- | |||
- | <code javascript> | ||
- | tfGet(" | ||
- | tfGet(" | ||
- | </ | ||
- | |||
- | |||
- | ===== Methods ===== | ||
- | |||
- | ==== (PersistentObject).hasPersistent( subid ) ==== | ||
- | |||
- | * //subid// is a persistence id fragment referring to some child data record for this object. | ||
- | * Returns: (Boolean) | ||
- | * 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: (Whatever type it was last set to) 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: (Whatever type it was last set to) 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: (Whatever type it was last set to) 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: | ||