Set Value on Custom Attribute
Hi All,
We've created a custom presentation for a custom workflow by following the tutorial provided on the wiki (https://jazz.net/wiki/bin/view/Main/RtcSdk20). The presentation displays a custom list box control (aka drop-down) with custom values instead of a button. The problem we are having is the form is not being flagged dirty when the control value is changed. The code where we set the value doesn't seem to quite be working. Here's the line:
fWorkingCopy.getWorkItem().setValue(getAttribute(),txtExposure.isEnabled())
I'm not quite sure how to get this to work for types other than boolean. Any suggestions?
Thanks in advance,
-Derry
We've created a custom presentation for a custom workflow by following the tutorial provided on the wiki (https://jazz.net/wiki/bin/view/Main/RtcSdk20). The presentation displays a custom list box control (aka drop-down) with custom values instead of a button. The problem we are having is the form is not being flagged dirty when the control value is changed. The code where we set the value doesn't seem to quite be working. Here's the line:
fWorkingCopy.getWorkItem().setValue(getAttribute(),txtExposure.isEnabled())
I'm not quite sure how to get this to work for types other than boolean. Any suggestions?
Thanks in advance,
-Derry
7 answers
we set the value doesn't seem to quite be working. Here's the line:
fWorkingCopy.getWorkItem().setValue(getAttribute(),txtExposure.isEnabled())
I'm not quite sure how to get this to work for types other than
boolean. Any suggestions?
Setting the value works analogously for types other than boolean. E.g. for
a string based attribute type:
fWorkingCopy.getWorkItem().setValue(getAttribute(), myStringValue)
This should automatically dirty the editor.
--
Regards,
Patrick
Jazz Work Item Team
So our custom presentation actually behaves more like a component than a single attribute. It is built to display 3 separate controls, 2 combo boxes and a text box. What we're struggling with is to have the controls updates programmatically and flag the form dirty. We can get the controls to update but the form doesn't get dirty and the values are not saved.
So do we 1.) 'addCustomAttribute' to the form and read data to and from these attribute?
2.) have hidden attributes on the form that we read and write to/from?
I think it's the 2 item. Other thoughts? Thanks in advance.
So do we 1.) 'addCustomAttribute' to the form and read data to and from these attribute?
2.) have hidden attributes on the form that we read and write to/from?
I think it's the 2 item. Other thoughts? Thanks in advance.
So I've begun implementing something like option 2. I've created a hidden field on the form and use it as my data store for the component. When a value changes on one of the controls it loops through the custom attributes and updates the value on the desired attribute.
Now the interesting part is that it doesn't have any problems when I create the initial form. But when I open the form a 2nd item I begin to get Class Cast Exceptions and an error message of "com.ibm.team.workitem.common.internal.model.impl.AttributeHandleImpl incompatible with com.ibm.team.workitem.common.model.IAttribute"
when looping over the workitem object custom attributes. Any suggestions?
Now the interesting part is that it doesn't have any problems when I create the initial form. But when I open the form a 2nd item I begin to get Class Cast Exceptions and an error message of "com.ibm.team.workitem.common.internal.model.impl.AttributeHandleImpl incompatible with com.ibm.team.workitem.common.model.IAttribute"
when looping over the workitem object custom attributes. Any suggestions?
So I've begun implementing something like option 2. I've created a
hidden field on the form and use it as my data store for the
component. When a value changes on one of the controls it loops
through the custom attributes and updates the value on the desired
attribute.
The usual approach would be
- define a custom attribute for the desired work item type
- bind your presentation to it in the Editor Presentation configuration
The presentation would then read and write this attribute (which
automatically dirties the editor).
To get the IAttribute, you can do something like this:
WorkItemUIWorkingCopy uiWorkingCopy= (WorkItemUIWorkingCopy)
workingCopy.getAdapter(IWorkItemUIWorkingCopy.class);
IAttribute attribute=
uiWorkingCopy.getResolvedWorkItem().findAttribute(fAttribute.getIdentifier());
Now the interesting part is that it doesn't have any problems when I
create the initial form. But when I open the form a 2nd item I begin to get Class Cast Exceptions and an error message of
"com.ibm.team.workitem.common.internal.model.impl.AttributeHandleImpl
incompatible with com.ibm.team.workitem.common.model.IAttribute"
when looping over the workitem object custom attributes. Any
suggestions?
If you use workitem.getCustomAttributes(), you can only assume that you
get handles back. To get the resolved attributes, you would use the
resolved work item, as in the code snippet above.
If you are already doing this, you may see
https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/89167,
which was recently fixed.
--
Regards,
Patrick
Jazz Work Item Team