-
1. Re: rich:pickLis dose not accept f:selectItems value as object
sivaprasad9394 Jun 20, 2013 5:32 AM (in response to wish79)you are using selectitem of jsf so its object type should be select item of list,not as integer.
<a4j:region>
<rich:pickList id="pickListPanel"
copyAllControlLabel="#{messages['button.SelectAll']}"
copyControlLabel="#{messages['button.Select']}"
removeControlLabel="#{messages['button.Remove']}"
removeAllControlLabel="#{messages['button.RemoveAll']}"
moveControlsVerticalAlign="middle" listsHeight="400px"
style="marigin-left:-2px;" sourceListWidth="250px"
targetListWidth="250px"
value="#{updateAttendanceHome.empAttendanceList}">
<f:selectItems
value="#{updateAttendanceHome.empNominatedList}" />
<a4j:support event="onlistchanged" ajaxSingle="true" />
</rich:pickList>
<rich:message id="picklist" for="pickListPanel">
</rich:message>
</a4j:region>
public List<SelectItem> getNominatedEmployeeList() {
----------------------------------------- UR code -----------------------
Employee emp;
String name;
Long eid;
while (updatedGapIte.hasNext()) {
trainingplanhistory = updatedGapIte.next();
emp = trainingplanhistory.getEmployee();
name = emp.getName();
eid = emp.getEid();
SelectItem val = new SelectItem(name + " - " + eid);
empNominatedList.add(val);
}
setEmpNominatedList(empNominatedList);
return empNominatedList;
}
Sure it will load the data in the picklist and works fine........
-
2. Re: rich:pickLis dose not accept f:selectItems value as object
wish79 Jun 20, 2013 3:15 PM (in response to sivaprasad9394)i know if i add value as primitive it will works but in my case the value it should be Object of my bean , i think i ahve to do it with converter .
-
3. Re: rich:pickLis dose not accept f:selectItems value as object
sivaprasad9394 Jun 20, 2013 11:47 PM (in response to wish79)Please have a look on here for <f:selectItems>,
http://stackoverflow.com/tags/selectonemenu/info
you can also use like below if you use s:selectItems,It depends on your project setup and implementation
converter="#{employeeIdConvertor}"> <s:selectItems value="#{participantGroupEmployeeMappingHome.empList}" var="empName" label="#{empName.name} - #{empName.eid}"/> /**
* @param empList the empList to set
*/
public void setEmpList(List<Employee> empList) {
this.empList = empList;
}
/**
* @return the empList
*/
public List<Employee> getEmpList() {
return empList;
}
Convertor like:
public Object getAsObject(FacesContext arg0, UIComponent arg1, String value)
{
// TODO Auto-generated method stub
Long conversionString = Long.parseLong(value);
return mapValue.get(conversionString);
}
public String getAsString(FacesContext arg0, UIComponent arg1, Object value)
{
// TODO Auto-generated method stub
mapValue.put(((Employee) value).getEid(), (Employee) value);
return ((Employee) value).getEid().toString();
}
You can alos use seam convert entity by default,
<s:selectItems value="#{emptrainingrolemappingHome.trainingRolesSelectItemList}" var="role"
label="#{role.trainrolename}"/>
<s:convertEntity></s:convertEntity>
-
4. Re: rich:pickLis dose not accept f:selectItems value as object
bleathem Jun 21, 2013 6:02 PM (in response to sivaprasad9394)Yes, a converter is required for the picklist to work with Objects.