InitBinders

Typical web forms have dates, currencies, and amounts. The values in the forms need to be bound to the form backing objects. Customization of how binding happens can be introduced using the @InitBinder annotation.

Customization can be done in a specific controller or a set of controllers using Handler Advice. This example shows how to set the default date format to use for form binding:

    @InitBinder 
protected void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, false));
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset