public abstract class ValueChangeConverter extends Object implements Converter
This converter offers you a template to do it transparently. To use it, just change your converters from:
public class YourConverter implements Converter { public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) { // ... } // ... }
to
public class YourConverter extends ValueChangeConverter { public Object getAsChangedObject(FacesContext context, UIComponent component, String submittedValue) { // ... } // ... }So, essentially, just replace
implements Converter
by extends ValueChangeConverter
and
rename the method from getAsObject
to getAsChangedObject
.
Note: the getAsString
method of your converter doesn't need to be changed.Constructor and Description |
---|
ValueChangeConverter() |
Modifier and Type | Method and Description |
---|---|
abstract Object |
getAsChangedObject(FacesContext context,
UIComponent component,
String submittedValue)
Use this method instead of
getAsObject(FacesContext, UIComponent, String) if you intend to perform the
conversion only when the submitted value is really changed as compared to the model value. |
Object |
getAsObject(FacesContext context,
UIComponent component,
String submittedValue)
If the component is an instance of
EditableValueHolder and the string representation of its old object
value is equal to the submitted value, then immediately return its old object value unchanged. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAsString
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue)
EditableValueHolder
and the string representation of its old object
value is equal to the submitted value, then immediately return its old object value unchanged. Otherwise, invoke
getAsChangedObject(FacesContext, UIComponent, String)
which may in turn do the necessary possibly
expensive DAO operations.getAsObject
in interface Converter
public abstract Object getAsChangedObject(FacesContext context, UIComponent component, String submittedValue)
getAsObject(FacesContext, UIComponent, String)
if you intend to perform the
conversion only when the submitted value is really changed as compared to the model value.context
- The involved faces context.component
- The involved UI component.submittedValue
- The submitted value.getAsObject(FacesContext, UIComponent, String)
the usual way.