Search in sources :

Example 31 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project benchmark by seelunzi.

the class TestController method initBinder.

/*    */
/*    */
@InitBinder
public /*    */
void initBinder(ServletRequestDataBinder binder) /*    */
{
    /* 37 */
    binder.registerCustomEditor(Date.class, new DateTimePropertyEditorSupport());
    /*    */
    /*    */
    /*    */
    /*    */
    /* 42 */
    binder.registerCustomEditor(String.class, new StringPropertyEditorSupport(true, false));
/*    */
}
Also used : DateTimePropertyEditorSupport(hry.core.util.springmvcPropertyeditor.DateTimePropertyEditorSupport) StringPropertyEditorSupport(hry.core.util.springmvcPropertyeditor.StringPropertyEditorSupport) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 32 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project spring-cloud by Rogge666.

the class BaseController method initBinder.

@InitBinder
protected void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
Also used : CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) SimpleDateFormat(java.text.SimpleDateFormat) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 33 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project BroadleafCommerce by BroadleafCommerce.

the class AdminBasicEntityController method initBinder.

// *********************************
// ADDITIONAL SPRING-BOUND METHODS *
// *********************************
/**
 * Invoked on every request to provide the ability to register specific binders for Spring's binding process.
 * By default, we register a binder that treats empty Strings as null and a Boolean editor that supports either true
 * or false. If the value is passed in as null, it will treat it as false.
 *
 * @param binder
 */
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    binder.registerCustomEditor(Boolean.class, new NonNullBooleanEditor());
}
Also used : NonNullBooleanEditor(org.broadleafcommerce.openadmin.web.editor.NonNullBooleanEditor) StringTrimmerEditor(org.springframework.beans.propertyeditors.StringTrimmerEditor) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 34 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project spring-framework by spring-projects.

the class InitBinderDataBinderFactory method isBinderMethodApplicable.

/**
 * Determine whether the given {@code @InitBinder} method should be used
 * to initialize the given {@link WebDataBinder} instance. By default we
 * check the specified attribute names in the annotation value, if any.
 */
protected boolean isBinderMethodApplicable(HandlerMethod initBinderMethod, WebDataBinder dataBinder) {
    InitBinder ann = initBinderMethod.getMethodAnnotation(InitBinder.class);
    Assert.state(ann != null, "No InitBinder annotation");
    String[] names = ann.value();
    return (ObjectUtils.isEmpty(names) || ObjectUtils.containsElement(names, dataBinder.getObjectName()));
}
Also used : InitBinder(org.springframework.web.bind.annotation.InitBinder)

Example 35 with InitBinder

use of org.springframework.web.bind.annotation.InitBinder in project disconf by knightliao.

the class BaseController method dateBinder.

/**
 * 绑定时间
 *
 * @param binder
 */
@InitBinder
protected void dateBinder(WebDataBinder binder) {
    // The date format to parse or output your dates
    SimpleDateFormat dateFormat = new SimpleDateFormat(WebConstants.TIME_FORMAT);
    // Create a new CustomDateEditor
    CustomDateEditor editor = new CustomDateEditor(dateFormat, true);
    // Register it as custom editor for the Date type
    binder.registerCustomEditor(Date.class, editor);
}
Also used : CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) SimpleDateFormat(java.text.SimpleDateFormat) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Aggregations

InitBinder (org.springframework.web.bind.annotation.InitBinder)35 SimpleDateFormat (java.text.SimpleDateFormat)13 CustomDateEditor (org.springframework.beans.propertyeditors.CustomDateEditor)13 ByteArrayMultipartFileEditor (org.springframework.web.multipart.support.ByteArrayMultipartFileEditor)9 DateFormat (java.text.DateFormat)6 StringTrimmerEditor (org.springframework.beans.propertyeditors.StringTrimmerEditor)3 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)3 PropertyEditorSupport (java.beans.PropertyEditorSupport)2 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)2 DateTimeFormatterBuilder (org.joda.time.format.DateTimeFormatterBuilder)2 DateConvertEditor (com.cdeledu.core.interceptors.DateConvertEditor)1 TodoPriorityPropertyEditor (com.in28minutes.springmvc.web.util.TodoPriorityPropertyEditor)1 DateTimePropertyEditorSupport (hry.core.util.springmvcPropertyeditor.DateTimePropertyEditorSupport)1 StringPropertyEditorSupport (hry.core.util.springmvcPropertyeditor.StringPropertyEditorSupport)1 NumberFormat (java.text.NumberFormat)1 NonNullBooleanEditor (org.broadleafcommerce.openadmin.web.editor.NonNullBooleanEditor)1 CustomNumberEditor (org.springframework.beans.propertyeditors.CustomNumberEditor)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 DefinitionTypeConverter (org.talend.components.service.rest.DefinitionTypeConverter)1 ConnectorTypologyConverter (org.talend.components.service.rest.dto.ConnectorTypologyConverter)1