Is there a way to programmatically bind form data to an object knowing the class type? I thought there would be something like
T instance = something.pleaseDoSomeMagicBind(class, request)
somewhere or something similar, but I had no luck so far.
Thank you
Thanks to Sotirios (you saved my sanity) hint, I've been able to achieve what I've been looking for and I'm leaving here my findings if anyone else is interested
final WebDataBinder binder = new WebDataBinder(BeanUtils.instantiate(clazz));
ServletRequestParameterPropertyValues values = new ServletRequestParameterPropertyValues(request);
binder.bind(values);
final BindingResult result = binder.getBindingResult();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With