I have a primefaces selectOneMenu and it uses a javax.faces.convert.Converter for displaying devices.
It works fine only when the key (device's id) is not greater than 127. When it's greater, after clicking a commandButton the selectOneMenu's arrow becomes red and the commandButton's action is not executed.
Why? Any ideas?
<p:selectOneMenu id="deviceActionParameter"
value="#{sm.ruleConfigureBean.deviceActionParameter}"
style="width:200px;">
<f:selectItems value="#{sm.ruleConfigureBean.sensors}"
var="device" itemLabel="#{device.name}" />
<f:converter converterId="deviceConverter" />
</p:selectOneMenu>
converter:
@FacesConverter(value = "deviceConverter")
public class DeviceConverter implements Converter {
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String key) {
DeviceDao deviceDao = GuiceSingleton.getInstance().getInstance(
DeviceDao.class);
try {
Device device = deviceDao.getDeviceById(new Long(key)); // this works
return device;
} catch (Exception e) {
return null;
}
}
@Override
public String getAsString(FacesContext context, UIComponent component,
Object value) {
if (value != null && value instanceof Device) {
Device device = (Device) value;
return "" + device.getIdDevice();
}
return "";
}
}