If I'm editing the values of TestObject taken from a database and I have parameters
name, email & telNo displayed on the screen, but dateCreated is not displayed
When I click 'save' values name, email & telNo of object testObject will be passed back to my Action from my JSP, dateCreated will now be
NULL as the value was never sent to the JSP in the first place.
Is there a way in which you should handle this properly in Struts2 to retain the original value from the database, or do you have to have a hidden
field on your JSP carrying the value of dateCreated?
I ask, because potentially you could have dozens of fields which you do not want on the screen, especially if only certain values are
editable on certain screens and it seems overkill to have to have them all as hidden fields.
I believe dateCreated will need to be inserted into DB only when the object was first created and not when the other values are updated. Probably you may change the business logic to just update the other fields if they have changed and not update dateCreated.
I understand Kevin what you are trying to do. what you want is just update fields that have been modified for that what you can do is in your action class you get name, email, telephone no. all that you have stored in suppose object1. for update procedure retrieve all current values of that particular entry in object2 by using some query. then modify object2 with updated values like object2.setName(object1.getName); and object2.setEmail(object1.getEmail) etc by this you will only modify necessary field and rest will not be changed
after this you can persist or merge or use your own save procedure on object2 for successful update in database