AnsweredAssumed Answered

setting and retreiving multi valued property

Question asked by tirthankar on Jun 28, 2010
Latest reply on Jul 20, 2010 by hyperation
First of all, let me apologise if the solution of my problem has already been posted here. I have searched the forums byt I have been unable to find any specific answer to my issue.

I have created a custom aspect where I have set some properties as multi valued.

<aspect name="st:myAspect">
  <title>Custom Model</title>
<properties>
<property name="st:header">
  <type>d:text</type>
  <multiple>true</multiple>
  </property>
<property name="st:paragraph">
  <type>d:text</type>
  <multiple>true</multiple>
  </property>
  </properties>
  </aspect>

I have set values to those properties as follows:
            
NamedValue namedvalue[] = new NamedValue[multiMetaDataMap.size()];
           
            Set<String> set = multiMetaDataMap.keySet();
           
            Iterator<String> it = set.iterator();
           
            int i = 0;
while (it.hasNext()) {
               String key = it.next();
               System.out.println(key+": ");
               for(String str : multiMetaDataMap.get(key))
               {
                  System.out.print(str);
                  System.out.println();
               }               
               namedvalue[i] = Utils.createNamedValue(key, multiMetaDataMap.get(key));
               namedvalue[i].setIsMultiValue(true);
               i++;
            }
where multiMetaDataMap is a HashMap of String key and and String [] value.

When I am querying the content later, I am getting a comma separated list of values when I am calling namedValue.getValue(), but when I am calling namedValue.getValues I am getting a null object.

String[] headerArr = namedValue.getValues();
               for(int h =0; h<headerArr.length;h++){
                  System.out.println("Header"+h+": "+headerArr[h]);
               }
here headerArr is coming as null.

but here 

String headerArr = namedValue.getValue();
System.out.println("Header: "+headerArr);
I am getting something like this.
[195, 205, 309, 361, 533, 523, 533, 538, 527, 684, 698, 691, 608, 582, 648, 687, 682, 680, 675, 842, 830, 864, 972, 1028, 1194, 1195, 1186, 1145]

I could have parsed the string to retrieve the values, but some of my values will themselves have comma in them and so that approach wont work.

I want to set the mutiple values and retrieve them as an array. Can some one please advise me what I am doing wrong and how I should approach this.

Please let me know if there is anything else I need to post and I will do that.

Thanks a lot for your help.

Outcomes