/** * Initialize a WebDataBinder with {@code @InitBinder} methods. * <p>If the {@code @InitBinder} annotation specifies attributes names, * it is invoked only if the names include the target object name. * @throws Exception if one of the invoked @{@link InitBinder} methods fails * @see #isBinderMethodApplicable */ @Override public void initBinder(WebDataBinder dataBinder, NativeWebRequest request) throws Exception { for (InvocableHandlerMethod binderMethod : this.binderMethods) { if (isBinderMethodApplicable(binderMethod, dataBinder)) { Object returnValue = binderMethod.invokeForRequest(request, null, dataBinder); if (returnValue != null) { throw new IllegalStateException( "@InitBinder methods must not return a value (should be void): " + binderMethod); } } } }
private WebDataBinderFactory createFactory(String methodName, Class<?>... parameterTypes) throws Exception { Object handler = new InitBinderHandler(); Method method = handler.getClass().getMethod(methodName, parameterTypes); InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(handler, method); handlerMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers); handlerMethod.setDataBinderFactory(new DefaultDataBinderFactory(null)); handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer()); return new InitBinderDataBinderFactory( Collections.singletonList(handlerMethod), this.bindingInitializer); }
/** * Initialize a WebDataBinder with {@code @InitBinder} methods. * <p>If the {@code @InitBinder} annotation specifies attributes names, * it is invoked only if the names include the target object name. * @throws Exception if one of the invoked @{@link InitBinder} methods fails * @see #isBinderMethodApplicable */ @Override public void initBinder(WebDataBinder dataBinder, NativeWebRequest request) throws Exception { for (InvocableHandlerMethod binderMethod : this.binderMethods) { if (isBinderMethodApplicable(binderMethod, dataBinder)) { Object returnValue = binderMethod.invokeForRequest(request, null, dataBinder); if (returnValue != null) { throw new IllegalStateException( "@InitBinder methods must not return a value (should be void): " + binderMethod); } } } }
/** * Initialize a WebDataBinder with {@code @InitBinder} methods. * <p>If the {@code @InitBinder} annotation specifies attributes names, * it is invoked only if the names include the target object name. * @throws Exception if one of the invoked @{@link InitBinder} methods fails * @see #isBinderMethodApplicable */ @Override public void initBinder(WebDataBinder dataBinder, NativeWebRequest request) throws Exception { for (InvocableHandlerMethod binderMethod : this.binderMethods) { if (isBinderMethodApplicable(binderMethod, dataBinder)) { Object returnValue = binderMethod.invokeForRequest(request, null, dataBinder); if (returnValue != null) { throw new IllegalStateException( "@InitBinder methods must not return a value (should be void): " + binderMethod); } } } }
/** * Initialize a WebDataBinder with {@code @InitBinder} methods. * <p>If the {@code @InitBinder} annotation specifies attributes names, * it is invoked only if the names include the target object name. * @throws Exception if one of the invoked @{@link InitBinder} methods fails * @see #isBinderMethodApplicable */ @Override public void initBinder(WebDataBinder dataBinder, NativeWebRequest request) throws Exception { for (InvocableHandlerMethod binderMethod : this.binderMethods) { if (isBinderMethodApplicable(binderMethod, dataBinder)) { Object returnValue = binderMethod.invokeForRequest(request, null, dataBinder); if (returnValue != null) { throw new IllegalStateException( "@InitBinder methods must not return a value (should be void): " + binderMethod); } } } }