I would like to use p:selectOneMenu with custom contents with p:columns (as shown in http://www.primefaces.org/showcase-labs/ui/selectOneMenu.jsf) and I would like to show the selected value in the drop-down field with less information than the ones shown in the drop-down list of possible values.
For example, the code below should show only bnkCod after selection (e.g. '1').
Instead it shows the concatenation of bnkCod and bnkNam (e.g. '1 Bank 1').
bnkCod and bnkNam are both String and the Converter works correctly.
Can anybody help me troubleshooting the problem ?
JSF:
<p:selectOneMenu value="#{bean.bank}" converter="bankCodeConverter" var="p">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{bean.banks}"
var="bank" itemLabel="#{bank.bnkCod}" itemValue="#{bank}"/>
<p:column>
#{p.bnkCod}
</p:column>
<p:column>
#{p.bnkNam}
</p:column>
</p:selectOneMenu>
Bean:
List<Bank> banks = new ArrayList<Bank>();
banks.add(new Bank("1","Bank 1"));
banks.add(new Bank("2","Bank 2"));
Converter:
@FacesConverter(forClass=Bank.class,value="bankCodeConverter")
public class MeansOfPaymentConverter implements Converter {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
//... retrieve bean
return bean.getBanksMap().get(value);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if(value instanceof Bank)
return ((Bank) value).getBnkCod();
else
return null;
}
}
I'm using PrimeFaces 3.4 and the problem shows up in both Safari 6.0 and Firfefox 18.0.1