I'm Migrating My project from seam 2 to JSF 2.x .
In seam 2 for enum's we have
<s:convertEnum />
which will call the converter when correct value is selected not the noSelectionOption value.
In JSF 2.x I have created My custom Converter like
@Named("enumConverter")
@ApplicationScoped
public class EnumConverter implements Converter {
public Object getAsObject(FacesContext context, UIComponent component, String key)
throws ConverterException {
if(!key.equalsIgnoreCase("-- Choose one --")){
// DO LOGIC
}
return null;
}
public String getAsString(FacesContext context, UIComponent component, Object object) {
}
Now the problem is in my view I'm using the converter like
<h:selectOneMenu value="#{user.DocumentType}" required="true">
<f:selectItem itemLabel="-- Choose one --" itemValue="#{null}" noSelectionOption="true"/>
<f:selectItems value="${user.Constants(user.statuses)}"
var="Val" itemLabel="#{user.Display(Val)}"
/>
<f:converter converterId="enumConverter"></f:converter>
</h:selectOneMenu>
Here if i select the NoSelectionOption then also my converter is getting called ,,, which should not happen and it should be called only if correct value is needed
in case of seam 2 converter only if correct value is selected then only converter will be called otherwise "value is required" is displayed.
Kindly please tell me ,what I'm missing here .... Appreciate and help ...
Thanks in advance