Example usage for org.springframework.web.bind WebDataBinder initDirectFieldAccess

List of usage examples for org.springframework.web.bind WebDataBinder initDirectFieldAccess

Introduction

In this page you can find the example usage for org.springframework.web.bind WebDataBinder initDirectFieldAccess.

Prototype

public void initDirectFieldAccess() 

Source Link

Document

Initialize direct field access for this DataBinder, as alternative to the default bean property access.

Usage

From source file:net.cyphoria.cylus.web.controller.KontoBearbeitenController.java

@InitBinder
private void initBinder(final WebDataBinder binder) {
    binder.initDirectFieldAccess();
}

From source file:app.web.AbstractController.java

@InitBinder
public void initBinder(WebDataBinder binder) {
    //IMPORTANT/*from   www  .  j  a  v  a 2 s  .  c o m*/
    binder.initDirectFieldAccess();
    binder.registerCustomEditor(PersistentObject.class, new PropertyEditorSupport() {
        @Override
        public void setAsText(String s) throws IllegalArgumentException {
            setValue(Db.get(ID.parse(s)));
        }

        @Override
        public String getAsText() {
            return getValue() != null ? ((PersistentObject) getValue()).getId().toString() : null;
        }
    });
    binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
        @Override
        public void setAsText(String s) throws IllegalArgumentException {
            try {
                setValue(DATE_FORMAT.parse(s));
            } catch (ParseException e) {
                throw new IllegalArgumentException(e);
            }
        }

        @Override
        public String getAsText() {
            return getValue() != null ? DATE_FORMAT.format(getValue()) : null;
        }
    });
}

From source file:com.virtusa.akura.common.controller.ManageSubTermController.java

/**
 * intiBinder method is to bind date class with the date format.
 * // ww  w . j a va 2  s  .c o m
 * @param binder - data binder used to register the Date objects.
 */
@InitBinder
public void initBinder(WebDataBinder binder) {

    binder.initDirectFieldAccess();
    SimpleDateFormat dateFormat = new SimpleDateFormat(DEFALUT_DATE_FORMAT);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}

From source file:com.virtusa.akura.common.controller.ManageHolidayController.java

/**
 * intiBinder method is to bind date class with the date format.
 *
 * @param binder - data binder used to register the Date objects.
 *//*from ww  w  .ja  v  a2  s .c  o m*/
@InitBinder
public void initBinder(WebDataBinder binder) {

    binder.initDirectFieldAccess();
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
}