I have a JSP page containing a ADD button to add the rows(a HTML code) via Javascript. I now need to retain the value in my form by replacing the codes in JSP by struts-tags. How should I then communicate from struts-tags and JS. Since all the HTML code lies in JS, how should it use struts-tags???
Please help!!
Your question is too vague to give an appropriate answer. However, I recently did something similar to this so I will try and give you a few guidelines.
1.) If you are hoping to populate these rows with information from the server this will require an ajax call. Most likely to an action that returns a snippet of jsp containing only a table row.
I suggest avoiding the struts2-jquery plugin for this unless you already are using it in your application. I would just use jQuery - http://api.jquery.com/jQuery.ajax/
2.) If you wish to gather user input in these rows you will just have to make sure to use appropriate naming for your fields.
Eg: In your java action you have a List< String > names. You would need to generate the following html via js.
3.) If you wish to keep track of the number of added rows you could use this in your jsp...
then within your javascript change the value of that input.
Hope one of those 3 helped!