It's all about the answers!

Ask a question

Getvalue of custom UI attribute


Antonio Bonanni (1111717) | asked Jan 10 '12, 10:40 a.m.
Hi,

i don't know how to get value from custom attributes using the getCustomAttributes() method: i've many custom attribute on my UI and when i'll submit the form ( a typical task item type with other custom fields ) i need to get the value. I tried with


List<IAttributeHandle> attributes = newState.getCustomAttributes();

for (IAttributeHandle iah : attributes){
Object obj = ((IAttribute)iah.getOrigin()).getValue(null, newState, monitor);

}


but when i run the code i get a NullPointerException

How can i solve ?

Thx.

4 answers



permanent link
sam detweiler (12.5k6195201) | answered Jan 10 '12, 11:52 a.m.
well, getValue() requires a non-null first parameter

Object com.ibm.team.workitem.common.model.IAttribute.getValue(IAuditableCommon auditableCommon, IWorkItem workItem, IProgressMonitor monitor) throws TeamRepositoryException
Returns the current -- calculated -- value of this attribute.

Parameters:
auditableCommon the common auditable library
workItem
monitor a progress monitor or null
------------------------------------------------------------
The auditable library provides access to IAuditables as an interface available on both the client and the server. On the client it can be obtained as a client library, on the server as a service.

================

Sam

permanent link
Antonio Bonanni (1111717) | answered Jan 11 '12, 5:17 a.m.
ok, so if i've to get attributes value ( server-side ) i need another method. There's something that can help me on the wiki ? I tried to find some docs but seems nothing found to solve.

Thanks

permanent link
sam detweiler (12.5k6195201) | answered Jan 11 '12, 9:51 a.m.
I think you are building an advisor or particpant.

If you are, then the AuditableCommon object is provided as part of the parameters to your advisor code.. (took me a while to find it too)



IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon();


Sam

permanent link
sundarrajan rangarajan (3134) | answered Feb 14 '12, 8:34 a.m.
I think you are building an advisor or particpant.

If you are, then the AuditableCommon object is provided as part of the parameters to your advisor code.. (took me a while to find it too)



IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon();


Sam



Please let me know what should this 'data' to be initialises?
thanks
Sundar

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.