I am storing data objects into an Array for initial rows and when user
submit the form i am getting the updated values by using the code
highlighted below

public ActionForward execute(ActionMapping mapping,
                     ActionForm form,
                     HttpServletRequest request,
                     HttpServletResponse response){

            DynaActionForm f = (DynaActionForm) form;
            Customer[] s = (Customer[])f.get("customer");

            System.out.println("Number of Rows on page :" + s.length);


               if (s.length!=0) {
                insertAllCustomer(s);
                f.set("customer", s);
            } else {
                Customer[] custArray = getAllCustomer();
                f.set("customer", custArray);
            }

          return (mapping.findForward("OK"));
        }

   the problem here is when i populate the data on page for the first time i
have 4 rows and then i add a new row by javascript, and i submit the page,
even then i get only 4 rows in execute method whereas i should get 5 rows so
that i can get the new added row data to create a new Customer bean and put
it back to Customer[] array (this is my collection)

Here is the loop for rows genration on JSP page :

 <logic:iterate id="customer" name="listTextForm" property="customer">
    <tr>
      <td><html:checkbox name="customer" property="id" value="yes"/></td>
      <td><html:text name="customer" property="firstName" /></td>
      <td><html:text name="customer" property="lastName" /></td>
      <td><html:text name="customer" property="address" /></td>
    </tr>
  </logic:iterate>



Is there something i am missing here ?... Waiting for a reply desperately
Thanks a lot.

On 12/17/05, atta-ur rehman <[EMAIL PROTECTED]> wrote:
>
> Irfan,
>
> How are you storing data required for initial rows? As a collection of
> objects in some scope that <logic:iterate> uses to paint them on the page?
>
> When user submits the page how are you getting the updated values?
> Populating the objects in the same collection or constructing a new
> collection and adding a object for each row?
>
> If that's the case, then all you need to do is reset the collection of
> objects to the new number of rows submitted by the user.
> Commons-Collection,
> which is required by Sturts(?) have a lazy-list which could be used for
> this
> purpose.
>
> ATTA
>
>
> On 12/16/05, Irfan Shaikh <[EMAIL PROTECTED]> wrote:
> >
> > Hi All,
> >          I am new to Struts and  need to implement a functionality where
> a
> > new row is added to table (generated using logic:iterate tag on JSP page
> )
> > on the fly(using javascript)  and handling newly added row in
> > DynaActionForm
> > so that row gets saved to database. Need to know how to create a bean
> for
> > newly added row.
> >
> > Suggestion will be highly appreciated.
> > Thanks in advance
> >
> >
>
>

Reply via email to