Class<?> type = creator.typeFor(method);
Object root;
try {
root = type.getDeclaredConstructor().newInstance();
} catch (Exception ex) {
throw new InvalidParameterException("unable to instantiate type" + type.getName(), ex);
}
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(root);
context.setTraceEvaluations(true);
context.put(Container.class, this.container);
VRaptorConvertersAdapter adapter = new VRaptorConvertersAdapter(converters, bundle);
Ognl.setTypeConverter(context, adapter);
for (Enumeration<?> enumeration = request.getParameterNames(); enumeration.hasMoreElements();) {
String key = (String) enumeration.nextElement();
String[] values = request.getParameterValues(key);
try {
if (logger.isDebugEnabled()) {
logger.debug("Applying " + key + " with " + Arrays.toString(values));
}
Ognl.setValue(key, context, root, values.length == 1 ? values[0] : values);
} catch (ConversionError ex) {
errors.add(new ValidationMessage(ex.getMessage(), key));
} catch (MethodFailedException e) { // setter threw an exception
Throwable cause = e.getCause();
if (cause.getClass().isAnnotationPresent(ValidationException.class)) {
errors.add(new ValidationMessage(cause.getLocalizedMessage(), key));
} else {
throw new InvalidParameterException("unable to parse expression '" + key + "'", e);
}
} catch (NoSuchPropertyException ex) {
// TODO optimization: be able to ignore or not
if (logger.isDebugEnabled()) {