You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anna Yates <ay...@hotmail.com> on 2004/01/20 05:21:00 UTC

Logic:iterate and html:text problem

I have multiple text boxes that I display on my page. Basically, I must show 
n rows (2 text boxes per row). I have no problem displaying them, but I am 
unclear on how to get the data back in a concise manner. To display, I use 
logic:iterate (see below):


logic:iterate name="custAcctForm" id="multiple" property="multipleIds"

bean:write property="profileName" name="multipleIds"

html:text property="userName" name="multipleIds"

html:text property="password" name="multipleIds"



In my form I have a Vector defined, private Vector multipleIds; The Vector 
holds a collection of my class, MultipleIdData which has 3 member variables: 
profileName, userName, and password. When I use the code above, it displays 
correctly, but the entered data goes nowhere. I have tried to define the 
"id" property to the "multipleIds" value, but it gives me an error that no 
collection was found. I was thinking I could index the values, but am 
unclear if this is the road I should take.  I have seen that if I initialize 
the Vector to some initial capacity, this will work, but I don't know how 
large this Vector will be. Does anyone have any suggestions. Thanks.

_________________________________________________________________
Check out the coupons and bargains on MSN Offers! 
http://shopping.msn.com/softcontent/softcontent.aspx?scmId=1418


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


RE: Logic:iterate and html:text problem

Posted by Andrew Hill <an...@gridnode.com>.
<snip>
but I don't know how large this Vector will be
</snip>

One trick is to submit the size back in a hidden field. In the forms reset()
method, you can use request.getParameter() (unless its a multipart form!) to
get the size and initialise the vector before the form is populated from the
request.

Id suggest however that since you have two two fields per row you may as
well use nested form beans for each row rather than vectors for each column.
(Also makes it much more convienient to add a third++ column later on if you
need to.)

There is a good tutorial on this at the keyboard monkey site:
http://www.keyboardmonkey.com/next/index.jsp

hth
Andrew

-----Original Message-----
From: Anna Yates [mailto:ayates2000@hotmail.com]
Sent: Tuesday, 20 January 2004 12:21
To: struts-user@jakarta.apache.org
Subject: Logic:iterate and html:text problem


I have multiple text boxes that I display on my page. Basically, I must show
n rows (2 text boxes per row). I have no problem displaying them, but I am
unclear on how to get the data back in a concise manner. To display, I use
logic:iterate (see below):


logic:iterate name="custAcctForm" id="multiple" property="multipleIds"

bean:write property="profileName" name="multipleIds"

html:text property="userName" name="multipleIds"

html:text property="password" name="multipleIds"



In my form I have a Vector defined, private Vector multipleIds; The Vector
holds a collection of my class, MultipleIdData which has 3 member variables:
profileName, userName, and password. When I use the code above, it displays
correctly, but the entered data goes nowhere. I have tried to define the
"id" property to the "multipleIds" value, but it gives me an error that no
collection was found. I was thinking I could index the values, but am
unclear if this is the road I should take.  I have seen that if I initialize
the Vector to some initial capacity, this will work, but I don't know how
large this Vector will be. Does anyone have any suggestions. Thanks.

_________________________________________________________________
Check out the coupons and bargains on MSN Offers!
http://shopping.msn.com/softcontent/softcontent.aspx?scmId=1418


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



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