> If I instantiate an object that has no custom class (so, an 
> EOEnterpriseObject), I can access its keys through valueFromKey().  How do I
> access its relationships?
>
> So, if I have a User object with a toCompany relationship, a custom class
> would allow me to just call User.toCompany.companyName for instance.
> However, if I try  to do that with an EOEnterpriseObject, they don't exist.
> No surprises really.  Unfortunately, valueFromKey("toCompany"); doesn't get
> me an EOEnterpriseObject containing the company record, so I'm somewhat at a
> loss.  There doesn't seem to be any obvious accessor methods for
> relationships in EOGenericRecord, but ... I assume I'm just missing it.  A
> pointer to this would be appreciated.  Doesn't need to be a complex answer
> as long as it lets me look up what I want in the help.

You really want to use customer EOs. In EOModeler, open the Inspector window
for your entity and enter a class name in the field (probably says
EOGenericRecord). The select Generate Java Files from the Property menu.
You'll be prompted to insert the records. Then, wherever you have
EOEnterpriseObject for your entities with custom classes, change the class
type to your custom class (in the above example, you'd have User.java and
Company.java).

Make sure that you've setup your relationships before you generate class
files. Also, make sure the relationship name is the one you want to use. The
default name is not always what you want. Once you have a User class
generated from EOModeler, User will include a method, NSArray toCompany()
which returns an array of Company. You can then use methods from NSArray to
work with the array.

One of the best features on WebObjects is EOF and the ability to add custom
code. You can add your own methods to a class that add functionality not
there by default then use those methods in WOBuilder.

Hope this helps

--Marc Respass
  mailto:[EMAIL PROTECTED]
  http://www.ultranet.com/~mer/

"Our aim is to make our standards ubiquitous."
Alec Saunders, manager of Microsoft's intelligent appliance division

Reply via email to