Child pages
  • To-one relationship components

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Here is how to use some ToOneRelationship components.


That's the default component which displays the to-one relationship. If you create a new D2W application, there should be a rule in you *user.d2wmodel* :

100 : (smartRelationship != null and smartRelationship.isToMany = 0 and task = 'inspect') => componentName = "ERD2WDisplayToOne" [com.webobjects.directtoweb.Assignment]

The default behavior of this component is to show all the fields of the object separate by ", " :

You can choose which propertyKey you want to display, and enable the link to go to the inspect page of this object :

100 : (task = 'inspect' and propertyKey = 'customer') => keyWhenRelationship = "name" [com.webobjects.directtoweb.Assignment]

100 : (task = 'inspect' and propertyKey = 'customer') => disabled = "false" [com.webobjects.directtoweb.Assignment]

In this exemple you will have a link to the customer your object is in relationship with.


This component performs an auto-completion to edit your relationship. You have to set the keyWhenRelationship rule, and it will fetch the database automatically :

Once you've clicked on the customer you want, your relationship is set. In this case we used two rules to set this component :

105 : (task = 'edit' and = 'Invoice' and propertyKey = 'customer') => componentName = "ERMD2WEditToOneTypeAhead" com.webobjects.directtoweb.Assignment

100 : propertyKey = 'customer' => keyWhenRelationship = "name" com.webobjects.directtoweb.Assignment


First, choose the propertyKey you want to set the to-one relationship, and assign the component :

100 : (task = 'edit' and propertyKey = 'currency') => componentName = "ERD2WEditToOneRelationship" [com.webobjects.directtoweb.Assignment]

Don't forget to set the keyWhenRelationship rule :

100 : (task = 'edit' and propertyKey = 'currency') => keyWhenRelationship = "code" [com.webobjects.directtoweb.Assignment]

You will have something like that :

You can work on the template to arrange it, but there's also different ways to set this component. You can set the toOneUIStyle rule like this :

100 : (task = 'edit' and propertyKey = 'currency') => toOneUIStyle = "popup" [com.webobjects.directtoweb.Assignment]

And you will have this behavior :