我有一个包含一个<h:selectManyMenu>
元素的 JSF 页面。value 属性指向在子类中定义为 type 的通用对象ArrayList<String>
。根据java文档,UISelectMany
应该从转换中返回它的值作为Collection
这个具体类型。但它作为String[]
数组返回。我错过了什么?
<h:selectManyMenu value="#{parameter.value}">
<f:selectItems value="#{parameter.valueList}"/>
</h:selectManyMenu>
public class Parameter<ArrayList<String>> extends ParentClass
{
private LinkedHashMap<Object, String> valueList;
public List<SelectItem> getValueList()
{
ArrayList<SelectItem> list = new ArrayList<SelectItem>();
for (Iterator<Object> i = this.valueList.keySet().iterator(); i.hasNext();)
{
Object value = i.next();
list.add(new SelectItem(value, this.valueList.get(value)));
}
return list;
}
}
public abstract class ParentClass<T>
{
private T value;
public T getValue() { return this.value; }
public void setValue(T t) { this.value = t; }
}