I have a custom converter to select a Country in a SelectOneMenu component:
File: address.jar
@FacesConverter(value="CountryConverter", forClass=Country.class)
public class CountryConverter implements Converter {
private CountryBean countryBean = CountryBean.getCountryService();
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
return countryBean.find(value);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value != null)
return ((Country)value).getcc_fips();
else
return null;
}
And this is the xhtml text:
File: Project root
<h:selectOneMenu id="country" value="#{cc.attrs.addrEntity.country}">
<f:selectItem itemLabel="Please select one..."
noSelectionOption="true" />
<f:selectItems value="#{cc.attrs.addrBean.countries}"
var="model"
itemLabel="#{model.name}"
itemValue="#{model}"
noSelectionValue="“no selection”"/>
<f:converter ConverterId="CountryConverter"/>
</h:selectOneMenu>
I have the converter in a file "address.jar" and when I try to open the page to write the address, then it responds saying "Expression Error: Object with name MyCustomCoverter not found.". Even thought when I copy the converter to the project where the xhtml files are, then it works ok. What can I do to solve this?
Why it doesn't work from a separated jar file?
Thanks.