Hi Zoheb,
If i understand it correctly, you need to use a common
jsp for Add and Edit, but don't know how to handle it with struts, right ?
I had a similar scenario in one of the applications that i worked on. Here's what i did.
1. Have the same form for the fields on the jsp.
2. Create the jsp and give all the fields there. Also give a hidden variable which is the id column in the database for your form details.
3. When you navigate to the form for add, that hidden variable wont have a value, whereas when you navigate for Edit, the Id will be set in it. (you need to handle this in your action class)
4. Now on click of submit button, invoke a javascript where you check the value of that hidden variable. If it is empty then invoke add function in action else invoke edit.
5. In you add/edit function you just need to set the user entered values in the pojo class for db table and invoke the saveOrUpdate() method of the persistence.
Let me know if this helps.
Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu |
krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------