Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



7 answers

Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
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?

0 votes


Permanent link
Ok I see that the initialization of the form actually provides proxies to the custom attributes instead of the attribute handle. This is causing the behavior I'm seeing. How can I use the attribute handle object to read / write to a custom attribute?

0 votes


Permanent link
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

0 votes


Permanent link
Thanks Patrick. That's exactly what I needed. I've got things working now.

0 votes


Permanent link
I have added an additonal example on how to create an attribute
presentation to the Wiki:
https://jazz.net/wiki/bin/view/Main/CalculatedAttributePresentation

--
Regards,
Patrick
Jazz Work Item Team

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943

Question asked: Aug 24 '09, 10:01 p.m.

Question was seen: 8,223 times

Last updated: Aug 24 '09, 10:01 p.m.

Confirmation Cancel Confirm