I have a picklist which requires a value to be provided every time for which I use required and I am using requiredMessage to display a message when a value is not entered. But both of them are not working for my picklist which is as shown below:
<p:pickList value="#{parameterValueDialog.selectedModelSeries}"
var="item" itemValue="#{item}" required="true"
converter="pickListConverter" requiredMessage="#{msg.validation_message}">
Does anyone have an idea as to how to solve this problem? Is this a problem of the Primefaces library itself?
EDIT: Posting getAsObject() method
@Override
public final Object getAsObject(final FacesContext ctx, final UIComponent component, final String string) {
Object returnObject = null;
Object dualList = ((PickList) component).getValue();
DualListModel<Item<?>> listModel = (DualListModel<NamedItem<?>>) dualList;
for (Item<?> item : listModel.getSource()) {
String id = String.valueOf(item.getId());
if (string.equals(id)) {
returnObject = item;
break;
}
}
if (returnObject == null) {
for (Item<?> item : listModel.getTarget()) {
String id = String.valueOf(item.getId());
if (string.equals(id)) {
returnObject = item;
break;
}
}
}
return returnObject;
}
getAsObject()of your converter. The problem might be caused in there. It might incorrectly have returned non-nullfor an empty string value. - BalusC