As an addition to the answer of BalusC:
The @NotNull
is specified on a DoiPool
object and not his name (that was shown in the text field). To make it work the text field needs to be bound to the validated field:
<h:inputText
id = "doiPool"
value = "#{detailModel.afterObject.doiPool}"
disabled = "#{facesContext.renderResponse}"
>
<f:converter converterId="ch.ethz.id.wai.doi.DoiPoolConverter"></f:converter>
</h:inputText>
The converter simply returns the getName()
of the object.
@FacesConverter( "ch.ethz.id.wai.doi.DoiPoolConverter" )
public class DoiPoolConverter implements Converter
{
/**
* This converter works only in the other direction.
*
* @return null
*/
@Override
public Object getAsObject( FacesContext facesContext, UIComponent uiComponent, String string )
{
return null;
}
@Override
public String getAsString( FacesContext facesContext, UIComponent uiComponent, Object object )
{
if ( object instanceof DoiPool )
{
return ( (DoiPool)object ).getName();
}
return null;
}
}