cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

What is usage of setNeed and setTargetObject.

Sriram_Rammohan
1-Visitor

What is usage of setNeed and setTargetObject.

What is usage of setNeed and setTargetObject. Can you pls assist on its need in column config

4 REPLIES 4

Hi Sriram,

Find below:

void setNeed(String need)

Sets the model attributes needed for this config. Model attributes are used (1) when the property has an id that doesn't map to the way the attribute is defined either by introspection or by logical attributes and (2) when multiple attribute values are needed to display column cells. To specify multiple model attributes, use a comma-separated list.

void setTargetObject(String targetObject)

Set the TargetObject. The infrastructure treats the objects that are returned by the ConfigDataBuilder as row objects that it works with when it builds the component model and renders the component. By configuring the targetObject property, the developer tells the infrastructure to use an alternate row object that is derived from the backing row object returned by the ConfigDataBuilder. The targetObject property value must correspond to an addressable property of the backing row object.
The target object will be used in the following places:
The row object supplied to data utilities
The object that soft attributes will be extracted from
The context object for the row checkbox, unless this is overridden by selectionObject

Here is an example: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS224363

Thanks,
Shirish

I've used setNeed and setTargetObject most often with tables where the query is actually on the link.  For example if you are building a table showing the ActionItems related to a ChangeRequest.  The query may be actually be returning the link object, not the Action Item object.  Then you would set these values.

Using setTargetObject():

ColumnConfig aiNumberColumn = factory.newColumnConfig("number","Action Item Number",true);
aiNumberColumn.setTargetObject("roleBObject");

This would get the "number" attribute of the RoleBObject.  Since "number" may be an attribute of the main object of the query, setting the TargetObject tells the builder exactly which object to get the number attribute from.

The RoleAObject is the ChangeRequest and the RoleBObject is the ActionItem.

Using setNeed():

JcaAttributeConfig orgAttribute = (JcaAttributeConfig)factory.newAttributeConfig("orgid");
orgAttribute.setNeed("organization.id");

It has something to do with logical attributes, but I'm not sure how to explain it.

To add more about setNeed, the other example is when multiple attribute values are needed to display column

For instance, check the task/assignment table on Home page. Description column can be used to get the description value from workitem object (logicalid :description) or from Action Item object (LogicalId :itemDescription) and is defined as following in java file.

col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.DESCRIPTION, true);

col.setNeed("description,itemDescription");

table.addComponent(col);

Regards,

Bhushan

Hallo,

I want to share another use case that I found out.

Assume you have a link object and you need to display name / number of attribute of both of the Role A / Role B. Then it is not possible to define newColumnConfig with name / number for both objects. So in this case you can define newColumnConfig with a different ID and setNeed to match to the id (ex: name / number). This way we don't need a separate datautility. 

Announcements


Top Tags