Good day.
I'm pretty new to JSF so maybe the question is obvious But I've
googled for 3 hours and found no solution.
I'm developing proto JSF application with JPA (as the point of
integration I'm using Spring managed beans in the JSF context).
There is a need to create the input for JPA object which references
the another. I've created the following converter:
public class SprPolConverter implements Converter {
private ISprPolDAO getDao(FacesContext context) {
return (ISprPolDAO) FacesContextUtils.getWebApplicationContext
(context).getBean("sprPolDAO");
}
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1,
String id) {
if (id == null )
return null;
Long _id = new Long(id);
return getDao(arg0).getById(_id);
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1,
Object obj) {
if (obj == null )
return null;
return "" + ((SprPol )obj).getId();
}
}
and registered it as the default converter for type
<converter>
<converter-for-class>com.uniqa.persistence.spr.common.SprPol</
converter-for-class>
<converter-
class>com.uniqa.ui.converters.spr.common.SprPolConverter</converter-
class>
</converter>
It's used anytime I submit the form - and returns the correct values
(looking in the logs - everything returned from converter is fine).
But I always receive the Validation error: Value is not valid....
any idea?
Best regards,
Ilya Dyoshin.