• cdi
  • components
  • contexts
  • converters
  • eventlisteners
  • exceptionhandlers
  • facesviews
  • filters
  • functions
  • managedbeans
  • push
  • resourcehandlers
  • scripts
  • servlets
  • taghandlers
  • utils
  • validators
  • viewhandlers
-
  • GenericEnumConverter
  • ListConverter
  • ListIndexConverter
  • SelectItemsConverter
  • SelectItemsIndexConverter
  • ValueChangeConverter

By default, JSF converters run on every request, regardless of whether the submitted value has changed or not. In case of conversion against the DB on complex objects which are already stored in the model in a broader scope, such as the view scope, this may result in unnecessarily expensive service/DAO calls. In such case, you'd like to perform the expensive service/DAO call only when the submitted value is really changed as compared to the model value.

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.

Documentation & Sources