You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by suhas <su...@techmas.hcltech.com> on 2000/07/12 13:04:08 UTC

Re: Long Story short

Hope u have the tag similar to this -

<html:form name="myForm>
<% int n= 0; %>

<logic:iterate id="someid"     name="myForm"    property="productList" >
// Here iterate tag is just acting as for loop .No use of scripting variable
"id"
    <html:text  name="myForm"    property="productList[n].productName"  />
// this will call getProductList ( index) followed by getProductName ( )
    <html:text  name="myForm"    property="productList[n].productPrice"  />
<% n ++ %>
</logic:iterate>
</html:form>

Here n is the index variable .    No need of using the **indexed iterate tag
** in above case .

Then have methods like

class myForm extends ActionForm {
private Vector  productList ;        //  contains list of  Product objects .
public Product getProductList(int index) {
    return (Product)productList(index);
}

public void setProductList( Vector list) {
    productList =  list ;
}
}

The class Product  implements Serializable {
private String productName ;
private String productPrice;

 //   getter and setters
public String getProductName ( ) {
    return productName ;
}
public void setProductName(String name ) {
    this.prodctName = name ;
}
public String getProductPrice () {
    return productPrice ;
}
public void setProductPrice(String price) {
    this.productPrice = price ;
}

}

----- Original Message -----
From: Frank Ling <st...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, July 12, 2001 12:04 AM
Subject: Re: Long Story short


> Hi, Dave:
>
> Thanks for the reply, I did have form-bean define at my struts-config.xml,
> in the matter fact, I did get all other form-bean field setting back form
> HTML form except this attributes array.
>
> The reason I used the changed indexed tag of html:text for iterate tag, is
> recently all the thread on this mailing list regarding for Iterate
property
> updating all recommend using your changed tag to have text name set like
> array items (I.e. attributes[n].value), then sounds like will help to set
> this value back to original array on my form bean. I just don't get it how
> this will be happen.
>
> I do have all my html:text name set like that way (i.e.
> attributes[n].value), but still get nothing setting back to my array, I do
> have all the setter method for element of the array.
>
> Do you know how your indexed tag will help on this matters?
>
> Thanks again.
>
> Frank Ling
>
>
> ----- Original Message -----
> From: <dh...@lexmark.com>
> To: <st...@jakarta.apache.org>
> Sent: Wednesday, July 11, 2001 2:22 PM
> Subject: Re: Long Story short
>
>
> >
> >
> > Frank,
> >
> > Do you have your struts-config set up correctly?  You might check that a
> new
> > form is not being created...
> >
> > Dave
> >
> > PS  Do you need the indexed naming?  If you don't, you don't need to use
> the
> > changed tags...
> >
> >
> >
> >
> > "Frank Ling" <fe...@interlock.lexmark.com> on
07/11/2001
> > 01:19:29 PM
> >
> > Please respond to struts-user%jakarta.apache.org@interlock.lexmark.com
> >
> > To:   struts-user%jakarta.apache.org@interlock.lexmark.com
> > cc:    (bcc: David Hay/Lex/Lexmark)
> > Subject:  Long Story short
> >
> >
> >
> > Hi, There:
> >
> > I send a long version story regarding for the Iteration tag with indexed
> tag
> > for property update. Not too much people response. Here is the short
> version
> > for that story.
> >
> > I get Dave hay's indexed tag work good with the Iterate tag for showing
> the
> > text field of my array attributes. I get attributes[n].value shows
> properly
> > on my JSP page. but nothing setting back to attributes array of my form
> > bean. the whole array is null after I received it on the next action
> class.
> >
> > Can anybody explain to me, why I get all these attributes[n].value shows
> as
> > the name of HTML text name, then that will automatically populate back
to
> my
> > array? It's not working that way for me right now. what I did wrong. Any
> > suggestion will be highly appreciated.
> >
> > Thanks
> >
> > Best Regards
> >
> > Frank Ling
> >
> >
> >
> >
> >
> >
> >
> >