jsf custom converter
I'm new to jsf 2.0 and spring 3.0 , i have a requirement to use custom converter in jsf 2.0.But it is not recognized,when i access my xhtml page it is 开发者_Go百科showing an exception "Named object not found" .I had used @FacesConverter annotation for the custom converter and it is using in the h:selectOneMenu.But i'm getting the error.could any one help in this...
@FacesConverter("selectItemsConverter")
public class SelectItemsConverter implements Converter {
public Object getAsObject(FacesContext context, UIComponent component, String value) {
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
}
}
h:selectOne Menu code is as follows:
<h:selectOneMenu style="width:100px;height:24px;" rendered ="#{row.edit}" value="#{row.modelo.country}" converter="selectItemsConverter" required="true" requiredMessage="#{msg['veci.admin.ccaa.pais.empty']}">
<f:selectItems value="#{communityView.countries}" var="con" itemLabel="#{con.nombrePais}"/>
</h:selectOneMenu>
Thank you to all.............
If you want to call the converter by its converterID you need to change your code as follows:
<h:selectOneMenu style="width:100px;height:24px;"
rendered ="#{row.edit}"
value="#{row.modelo.country}"
required="true"
requiredMessage="#{msg['veci.admin.ccaa.pais.empty']}">
<f:converter converterId="selectItemsConverter"/>
<f:selectItems .../>
</h:selectOneMenu>
The converter attribute of the h:selectOneMenu
needs a fully qualified class name such as:
<h:inputText
converter="javax.faces.convert.IntegerConverter" />
If you want to give your converter a custom id use the value
parameter:
@FacesConverter(value="selectItemsConverter")
精彩评论