@Test public void test_determineControllerMethodParameters_bindCollection() throws Exception { MockHttpServletRequest req = new MockHttpServletRequest(); req.addParameter("helper.name", "Helper"); req.addParameter("helper.numbers", new String[] { "1", "2", "3" }); Map<Class<?>, Object> argumentsByType = new HashMap<Class<?>, Object>(); argumentsByType.put(HttpServletRequest.class, req); Method method = MockController.class.getMethod("action", MockDomainObject.class); Object[] temp = UiFrameworkUtil.determineControllerMethodParameters(controller, method, argumentsByType, conversionService, applicationContext); MockDomainObject bound = (MockDomainObject) temp[0]; Assert.assertNotNull(bound); Assert.assertEquals("Helper", bound.getName()); Assert.assertNotNull(bound.getNumbers()); Assert.assertEquals(3, bound.getNumbers().size()); Assert.assertTrue(bound.getNumbers().contains(1)); Assert.assertTrue(bound.getNumbers().contains(2)); Assert.assertTrue(bound.getNumbers().contains(3)); }
public static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType, ConversionService conversionService, ApplicationContext applicationContext) throws RequestValidationException { Class<?>[] types = method.getParameterTypes(); int numParams = types.length; Object[] ret = new Object[numParams]; for (int i = 0; i < numParams; ++i) { Object result = determineArgumentValue(controller, argumentsByType, new MethodParameter(method, i), conversionService, applicationContext); if (result instanceof BindingResult) { ret[i] = ((BindingResult) result).getTarget(); if ((i + 1 < numParams) && Errors.class.isAssignableFrom(types[i + 1])) { ret[i + 1] = result; i += 1; } } else { ret[i] = result; } } return ret; }
UiFrameworkUtil { public static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType, ConversionService conversionService, ApplicationContext applicationContext) throws RequestValidationException { Class<?>[] types = method.getParameterTypes(); int numParams = types.length; Object[] ret = new Object[numParams]; for (int i = 0; i < numParams; ++i) { Object result = determineArgumentValue(controller, argumentsByType, new MethodParameter(method, i), conversionService, applicationContext); if (result instanceof BindingResult) { ret[i] = ((BindingResult) result).getTarget(); if ((i + 1 < numParams) && Errors.class.isAssignableFrom(types[i + 1])) { ret[i + 1] = result; i += 1; } } else { ret[i] = result; } } return ret; } }
UiFrameworkUtil { public static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType, ConversionService conversionService, ApplicationContext applicationContext) throws RequestValidationException { Class<?>[] types = method.getParameterTypes(); int numParams = types.length; Object[] ret = new Object[numParams]; for (int i = 0; i < numParams; ++i) { Object result = determineArgumentValue(controller, argumentsByType, new MethodParameter(method, i), conversionService, applicationContext); if (result instanceof BindingResult) { ret[i] = ((BindingResult) result).getTarget(); if ((i + 1 < numParams) && Errors.class.isAssignableFrom(types[i + 1])) { ret[i + 1] = result; i += 1; } } else { ret[i] = result; } } return ret; }  }
UiFrameworkUtil { public static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType, ConversionService conversionService, ApplicationContext applicationContext) throws RequestValidationException { Class<?>[] types = method.getParameterTypes(); int numParams = types.length; Object[] ret = new Object[numParams]; for (int i = 0; i < numParams; ++i) { Object result = determineArgumentValue(controller, argumentsByType, new MethodParameter(method, i), conversionService, applicationContext); if (result instanceof BindingResult) { ret[i] = ((BindingResult) result).getTarget(); if ((i + 1 < numParams) && Errors.class.isAssignableFrom(types[i + 1])) { ret[i + 1] = result; i += 1; } } else { ret[i] = result; } } return ret; }  static Object executeControllerMethod(Object controller, String httpRequestMethod, Map<Class<?>, Object> possibleArguments,
                                                 ConversionService conversionService, ApplicationContext applicationContext); static Object invokeMethodWithArguments(Object target, Method method, Map<Class<?>, Object> possibleArguments,
                                                   ConversionService conversionService, ApplicationContext applicationContext); static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType,
                                                               ConversionService conversionService, ApplicationContext applicationContext); static Object determineArgumentValue(Object controller, Map<Class<?>, Object> valuesByType, MethodParameter methodParam,
                                                ConversionService conversionService, ApplicationContext applicationContext); @SuppressWarnings("unchecked") static T findCause(Throwable t, Class<T> lookFor); static String getMessage(MessageSourceResolvable msg); static boolean checkAndSetDevelopmentModeForProvider(String key, Object provider); static DateFormat getDateFormat(AdministrationService administrationService, Locale locale); static DateFormat getDateTimeFormat(AdministrationService administrationService, Locale locale); static DateFormat getTimeFormat(AdministrationService administrationService, Locale locale); }
UiFrameworkUtil { public static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType, ConversionService conversionService, ApplicationContext applicationContext) throws RequestValidationException { Class<?>[] types = method.getParameterTypes(); int numParams = types.length; Object[] ret = new Object[numParams]; for (int i = 0; i < numParams; ++i) { Object result = determineArgumentValue(controller, argumentsByType, new MethodParameter(method, i), conversionService, applicationContext); if (result instanceof BindingResult) { ret[i] = ((BindingResult) result).getTarget(); if ((i + 1 < numParams) && Errors.class.isAssignableFrom(types[i + 1])) { ret[i + 1] = result; i += 1; } } else { ret[i] = result; } } return ret; }  static Object executeControllerMethod(Object controller, String httpRequestMethod, Map<Class<?>, Object> possibleArguments,
                                                 ConversionService conversionService, ApplicationContext applicationContext); static Object invokeMethodWithArguments(Object target, Method method, Map<Class<?>, Object> possibleArguments,
                                                   ConversionService conversionService, ApplicationContext applicationContext); static Object[] determineControllerMethodParameters(Object controller, Method method, Map<Class<?>, Object> argumentsByType,
                                                               ConversionService conversionService, ApplicationContext applicationContext); static Object determineArgumentValue(Object controller, Map<Class<?>, Object> valuesByType, MethodParameter methodParam,
                                                ConversionService conversionService, ApplicationContext applicationContext); @SuppressWarnings("unchecked") static T findCause(Throwable t, Class<T> lookFor); static String getMessage(MessageSourceResolvable msg); static boolean checkAndSetDevelopmentModeForProvider(String key, Object provider); static DateFormat getDateFormat(AdministrationService administrationService, Locale locale); static DateFormat getDateTimeFormat(AdministrationService administrationService, Locale locale); static DateFormat getTimeFormat(AdministrationService administrationService, Locale locale);  }