It's all about the answers!

Ask a question

Java API extending - Work Item Attribute data type to accept Java List

Peter Moraza (481924) | asked Oct 06 '14, 8:44 p.m.
edited Oct 06 '14, 8:45 p.m.

I'm using RTC 4.0.3. Is there a work item attribute data type that is compatible with List<String>? I am working with a custom attribute with data type declared as Large HTML. The following code generates the exception: java.util.ArrayList incompatible with java.lang.String

List<String> tmp = new ArrayList<String>();
// assign values to strings and add to tmp List
workItemCopy.setValue(iAttribute, tmp);

Would the attribute "String list" data type handle List<String>?



Peter Moraza commented Oct 07 '14, 1:19 a.m.

The "String list" type does allow setValue with List<String> data, but the update is written to the History tab of the work item, not to the custom attribute tab I am directing the update to. Worst case scenario for me is to plain String data to the custom attribute tab, but I will do that if that is the only option.

2 answers

permanent link
Ralph Schoon (63.2k33646) | answered Oct 07 '14, 3:04 a.m.
edited Oct 07 '14, 3:07 a.m.
Large HTML is of course incompatible with String List. It is just an attribute maintaining a single object.

I am not completely sure which collection class is used to wrap the strings in the StringList type, I would suggest to read the value of such an attribute and have a look at the types involved in the debugger. That always helps to understand what you get and have to provide.

With respect to where data goes, I think you got things wrong. Data does not go to any tab at all. The data goes into an attribute. You have to configure a presentation that shows the attribute in the editor presentation section.

Although for simple custom attributes, in the Eclipse client (and only there) a custom attribute tab is automatically maintained, this may only show simple attributes in the way you want them by default. I would therefore suggest to create an editor presentation for the string list attribute and see if it is displayed as you want it to.

Peter Moraza commented Oct 07 '14, 9:45 p.m.

Thanks as always RS for your very helpful comments and suggestions. I definitely did misspeak with regard to data "to a tab".

I am still researching this. For my requirement, I may pass a String to setValue targeting a Large HTML attribute after all.


permanent link
Eric Jodet (6.3k5111120) | answered Oct 07 '14, 3:51 a.m.
I would try:
String[] _stringValues= new String[] { "String 1", "String 2" };
_listValue= new ArrayList<String>(_stringValues);
workItemCopy.setValue(iAttribute, _listValue);


Peter Moraza commented Oct 07 '14, 6:27 p.m.

Hi Eric,

That is very similar to what I am doing to generate the List. Thanks!


Eric Jodet commented Oct 08 '14, 2:08 a.m.

 Hello Peter,

well - this how our tests for String List Attributes are implemented.
So it should work.


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.