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));
}
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());
}
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()));
}
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);
}
Aggregations