I want to make an update form for a bean X. This bean lets say it has fields A, B, C, D. In my form I want to update just fields A, B and let C and D untouched. Is there a way to bind bean X to the update form with just fields A and B, so that when i submit the form C and D won't be changed ?
I know i can add hidden fields for C and D but what if these are not primitive fields, they are other beans or collections.
I know another solution would be to create a XUpdateBean that will have only fields A and B and after form submit copy the fields from XUpdateBean to my X bean.
Is there another way to this update better in Spring 3 MVC?
You could have a command-Object/form-barking-Bean that contains only the fields you need.
In the controller you have to load the bean X, and need to update its fields with the one from the commandObject.
May you can also think of not having an extra class for the commandObject, instead use class BeanX. But of course you need two instances of BeanX, one for the commandObject and one for bean x.
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