Basic Customization > User Interface Customization > Gathering the Data for the UI > NmObject Utilities > Configure a Different Target Object
  
Configure a Different Target Object
This procedure describes how to specify a target object for an attribute panel or a row that is different than the datum object. The unique identifier for row selections and actions will be obtained from the target object and the target object is also what will be passed to the data utility that creates the value displayed for an attribute. The target object must be obtainable from the datum object via a getter method. For tables and trees, a target object can be specified for the entire table or tree or for just certain columns. For panels, a target object can be specified for the entire panel or just certain attributes.
The target object must be retrievable via a “getter” method on the datum object.
When you configure a different target object for a table or tree that has row selection and/or row action menus, the target object should be one of the following types so that a unique row identifier can be determined:
Persistable
WTReference
ObjectIdentifeir
NmObject
NmOid
NmSimpleOid
Use one of the following methods to set the target object:
JCATableConfig.setTargetObject() to set the target object for an entire table or tree
JCAColumnConfig.setTargetObject() to set the target object for a specific table or tree column
AttributePanelConfig.setTargetObject() to set the target object for an entire attribute panel
AttributeConfig.setTargetObject() to set the target object for a single attribute in a panel
If you set the target object for the whole panel or table, that target object will be used for every attribute/column unless overridden by the AttributeConfig or JCAColumnConfig. If a target object is specified for the entire panel or table and you want to use the datum object for a specific attribute or column, you can set the target object to “” on the attribute or column config.
For example:
JcaTableConfig table = (JcaTableConfig)factory.newTableConfig();
table.setTargetObject(“foo”);
ColumnConfig c = factory.newColumnConfig("name",label,false);

ColumnConfig col = factory.newColumnConfig("thing1",label,false);
col.setTargetObject("");
ColumnConfig col2 = factory.newColumnConfig("thing2",label,false);
col2.setTargetObject("bar");
In the above example, for each column the DefaultNmObjectDataUtility will try to create an NmObject from the targetObject. For the name column, the targetObject is retrieved by calling getFoo() on the row datum because “foo” is the target object configured for the table and it has not been overridden for the name column. For thing1, the targetObject is the row datum because “” is configured. For thing2, the targetObject is retrieved by calling getBar() on the row datum.
How is this different than configuring bean properties?
You may be wondering how this configuration of targetObject differs from a configuration that uses bean-style property configuration. For example the following configurations both end up displaying getFoo().getBaz() of the row objects returned for your table:
ColumnConfig colA = factory.newColumnConfig("thing1",label,false);
colA.setTargetObject("foo");
colA.setNeed("baz");
ColumnConfig colB = factory.newColumnConfig("thing2",label,false);
colB.setTargetObject("");
colB.setNeed("foo.baz");
The small difference is that colA would use ‘foo’ as the target object sent into the DefaultNmObjectUtility and the DataUtility for the row etc. And colB would use the original row object.