Hi, I need to get a multiple select drop down component.
How can this be acheieved?
I tried
<h:selectManyListbox id="groups" value="#{customerController.selected.groups}">
<f:selectItems value="#{groupController.itemsAvailableSelectMany}"/>
</h:selectManyListbox>
I get the Objects displayed, but I need the name to be displayed instead.
And when I try to submit, I get an error j_idt50:groups: Validation Error: Value is not valid
though the values are displayed correct in the view source
<select id="j_idt50:groups" name="j_idt50:groups" multiple="multiple" size="2">
<option value="1" selected="selected">com.entity.Group@ffc9ca</option>
<option value="2">com.entity.Group@118f163</option>
</select>
Here is my code
@ManagedBean (name="groupController")
@SessionScoped
public class GroupController {
public SelectItem[] getItemsAvailableSelectMany() {
return JsfUtil.getSelectItems(ejbFacade.findAll(), false);
}
}
public class GroupConverter implements Converter {
public
String getAsString(FacesContext facesContext, UIComponent component, Object object) {
if (object instanceof Group) {
Group o = (Group) object;
return new String(new Integer(o.getGroupId()).toString());
}
}
}