If you will submit multiple EmpBean, your action will need some sort
of Collection<EmpBean> (a List or Map I commonly use) with its getter
& setter.

You must name correctly your input parameters so that the
ParameterInterceptor assign them right, that is, you name it as the
collection variable, indexed by some key (if using a List the index is
an integer >= 0, if using a Map, anything that can be used as a map
key.)

when you "Add" a new EmpBean, you create hidden fields with the following names:

<input type="hidden" name="myCollection[0].first_name" value="..." />
<input type="hidden" name="myCollection[0].last_name" value="..." />

<input type="hidden" name="myCollection[1].first_name" value="..." />
<input type="hidden" name="myCollection[1].last_name" value="..." />

and so on...

the part of adding the fields to a table with jQuery is pure client
side javascript so it is independent of using S2 or any other web
framework, just remember to add a hidden input field in the client
side table to preserve the data you will submit at once later.

2010/1/6 sharath karnati <karna...@yahoo.com>:
> Dear All,
>
>   I'm having following requirement and can you please let me know how to do 
> this using struts2.
>
>   Say EmployeeAction having EmpBean (getter & setter)
>
>   EmpBean:
>
>      private long emp_id;
>      private String first_name;
>      private String last_name;
>      private String class_name;
>
>
> In user interface(UI), I have 2 text fields for entering first_name and 
> last_name.. when user enters this information and selecting 'Add' button it 
> will display one row in same page like below
>
>     First Name     Last Name
>      Mike              Rojer               Remove
>      Smith            Gates              Remove
>
>    After entering multiple entries user will submit the page.
>
>   I'm using jQuery, how to add multiple rows dynamically pressing 'Add' 
> button and how to populate these beans in backend EmployeeAction...
>
>    Can anyone please let me know how to solve this problem using Struts2 + 
> jQuery.
>
> Thanks for your help.
>
> Regards,
> Sharath.
>
>
>
>
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to