1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
public class VilleConverter implements Converter {
@ManagedProperty("#{dataReferenceHelper}")
private DataReferenceHelper dataReferenceHelper;
...................
/* (non-Javadoc)
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
*/
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
Ville ville = null;
if (value != null && !StringUtils.isEmpty(value.trim())) {
ville = dataReferenceHelper.getVille(value);
}
return ville;
}
/* (non-Javadoc)
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
*/
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
if (value instanceof Ville) {
Ville ville = (Ville) value;
return ville.getVillePk().toString();
}
return null;
} |
Partager