I've run into a problem with displaying custom content in my SelectOneMenu. I'm using Primefaces 3.5 right now and I tested the example from the showcase and it works fine, so unfortunately the problem is PEBCAC.
This is my converter code:
@Override
public Object getAsObject(FacesContext ctx, UIComponent component, String id)
{
groups = getGroups();//gets the groups here
pType toReturn = new pType();
if(groups.size()>0){
toReturn = groups.get(0);
return toReturn;
}
return "";
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object o)
{
if (o == null || o.equals(""))
{
return "---";
} else
{
try{
pType val = (pType)o;
return String.valueOf(val.getRecordID());
}catch(Exception ex){
ex.printStackTrace();
return "---";
}
}
}
This is the xhtml I'm working with right now:
<p:selectOneMenu value="#{controller.selectedVal}"
rendered="#{controller.showMenu}" effect="fade"
converter="converter" panelStyle="width:150px" var="p"
style="width:160px" filter="true" filterMatchMode="contains">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems var="pType"
itemLabel="#{controller.getNumber(pType)}"
itemValue="#{pType}" value="#{controller.savedValues}">
<p:column>#{p.var1} - #{p.var2}
</p:column>
</f:selectItems>
</p:selectOneMenu>
The controller is a managedbean that is SessionScoped. The variable savedValues is a list of the objects and it does populate with the right data and has data when its called. Right now with the code above, the list just opens up and there's no data inside it. If I switch the var in to "pType" instead of "p", the drop down menu will have a list of the values gotten from controller.getNumber(pType), although there is no custom data being loaded into the menu. But all the examples I've seen show that the variable used is coming from selectOneMenu, which is also something I'm a bit confused on as it seems like it should always be coming from the value field of selectItems.