Helma logo
helma.org » Home > Stories > HopObject.getById()

HopObject.getById()

If called on a HopObject instance, this getById() retrieves a child object by ID. If called on a HopObject constructor, it retrieves any persistent HopObject of that prototype.

Syntax
HopObject.getById(stringOrNumber)

Example
//get the child with id 17
var child = root.getById(17);
writeln(child._id);
17

//get the child at index 17 of the HopObject's children-collection
child = root.get(17);
writeln(child._id);
42

//get the child with the name "17" (_children.accessname = name) of the HopObject
child = root.get("17");
writeln(child._id);
69
writeln(child.name);
17

//get the persistent HopObject with prototype "Page" and id 127
var page = HopObject.getById(127, "Page");
writeln(page._id);
127

//get the persistent HopObject with prototype "Page" and id 127
var page = Page.getById(127);
writeln(page._id);
127


... comment


Page last modified on 2005-02-15 17:12 by hns