Helma logo
helma.org » Home > docs > tutorial > Attaching HopObjects

Attaching HopObjects

We now successfully established a database connection from Helma to the MySQL server and mapped the relational table data to HopObject properties. But still, these derived HopObjects are freely floating around in Helma space. There is no possibility to access HopObjects, yet. Helma even does not know about them. We need a HopObject that already is accessible, that is known by Helma. That's what the Root HopObject of an application is for.

One could say the Root HopObject is the default place for Helma to go: "go for the root", that's what Helma can do very good. When you enter the base URL of any application, Helma is going for Root, is retrieving data from the Root HopObject first.

And as any HopObject has its prototype, there is also one for Root, ie. the directory called – you guessed it – Root.

To attach our Person HopObjects onto Root, we have to create yet another file called type.properties, this time for the Root prototype. It contains the following lines and goes into the – you guessed it again – Root folder.

apps/addressbook/Root/type.properties:

_children            = collection(Person)
_children.accessname = ID
_children.order      = LASTNAME asc
You can read this assignment the way "attach all HopObjects of the prototype Person as subnodes, indexed by the column ID of the corresponding relational table PERSON, and sorted ascending by the values in column LASTNAME".

And because we save this document in Root they will be attached to the HopObject Root (you are right when you assume that you could do this with any other HopObject simply by creating such type.properties for its prototype – in fact, we have done it before with the Person prototype).


Up: Tutorial
Previous: "Wiring" The Prototype Next: Shaping The Output

... comment


Page last modified on 2005-10-17 18:16 by czv

 
tomdiesel, Tuesday, 5. September 2006, 20:49
Misspelling in Tutorial
As far as I can see "Person" is misspelled in this Tutorial.
it should be spelled "PERSON".
At least it works that way.

_children = collection(PERSON)
_children.accessname = ID
_children.order = LASTNAME asc

... link  

 
czv, Thursday, 7. September 2006, 19:28
Hi tomdiesel! "Person" in that line refers to the prototype "Person" and not the db table "PERSON", so I think "Person" should be correct. Did you name your prototype "PERSON" instead of "Person" (how did you spell the directory name)?

... link  


... comment