In a my applications I have defined a property of an object as a LinkedHashSet. The property I fill with values from a multi-value field:
Vector<String> ctrs = doc.getItemValue("countries");
LinkedHashSet<String> items = new LinkedHashSet<String>();
for (int i = 0; i < ctrs.size(); i++){
items.add(ctrs.get(i));
}
employee.setCountry(items);
On an XPage I would like to display the values as followed:
<xp:inputText id="inputCountries" value="#{employeeBean.employee.Country}">
<xp:this.multipleSeparator><![CDATA[#{javascript:var val = getComponent("contractType").getValue();
if (val == "Multi"){
return ",";
}}]]></xp:this.multipleSeparator>
</xp:inputText>
Depending on the type of employee this field may be single or multi-value.
When view the XPage the returned value is displayed as followed:
[Sweden, Denmark, Estonia]
Ofcourse I would have it displayed as multi-value. What should I do to correct this?
Here an example, the first as single/ the second as multi value field:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:inputText id="singleValue" multipleSeparator=",">
<xp:this.value><![CDATA[#{javascript:var items:java.util.Set = new java.util.LinkedHashSet();
items.add("Sweden");
return items.toArray();}]]>
</xp:this.value>
</xp:inputText>
<br></br>
<br></br>
<xp:inputText id="multiValue" multipleSeparator=",">
<xp:this.value><![CDATA[#{javascript:var items:java.util.Set = new java.util.LinkedHashSet();
items.add("Sweden");
items.add("Denmark");
items.add("Estonia");
return items.toArray();}]]>
</xp:this.value>
</xp:inputText>
</xp:view>
The output on a browser looks like:
Sweden
Sweden,Denmark,Estonia