logic:iterate in struts

Z

Zhao

Hi, I am using logic:iterate of struts.
Here is the issue I am facing. I need to present a table
with mutiple rows. in each row there is a text field, "add" (see the
code below), containing
number of items added to shipping cart and another static text
field (label type), "available", containing the maximum number can be
enter into field "add". When users click at the button "Add to cart",
I need to verify if the entered number is within the range of
0<add<available.

My question is: in order to verify the entered number, I need to
compare it with available. How can I get the "available" field
identified?
I used bean:write and couldn't find a attribute like "id" to place the
row
number on it (I plan to use a row number, "index" (see code below), to
connect "available", "add" and "Add to cart" so that when "Add to
cart" is
clicked struts can carry out the verification to compare "add" and
"available".

I am not sure if my description was clear enough so far. I tried to
use a
hidden field to contain all the info needed for verification using

<td><html:hidden property="availableBoo_<%= index %>" value="?"></td>

but got "Unterminated tag" error.

In other words, how can I compare columns in logic:iterate for
verification?













=========================== the jsp code =======================
<table border="">
....
<logic:iterate id="MyItem" name="ListForm" property="ItemList"
indexId="index">
<tr>
...
<td><bean:write name="MyItem" property="available"/> </td>
<td><html:text property="orderedNum" value="1"/><html:button
property="add" value="Add to cart"/> </td>
</tr>
</logic:iterate>
</table>

Thanks

Zhao
 
B

Ben Jessel

I am not sure if my description was clear enough so far. I tried to
use a
hidden field to contain all the info needed for verification using

<td><html:hidden property="availableBoo_<%= index %>" value="?"></td>

but got "Unterminated tag" error.

Try <td><html:hidden property="availableBoo_<%= index %>" value="?"/></td>
 
S

Sudsy

Zhao said:
Hi, I am using logic:iterate of struts.
Here is the issue I am facing. I need to present a table
with mutiple rows. in each row there is a text field, "add" (see the
code below), containing
number of items added to shipping cart and another static text
field (label type), "available", containing the maximum number can be
enter into field "add". When users click at the button "Add to cart",
I need to verify if the entered number is within the range of
0<add<available.

My question is: in order to verify the entered number, I need to
compare it with available. How can I get the "available" field
identified?
I used bean:write and couldn't find a attribute like "id" to place the
row
number on it (I plan to use a row number, "index" (see code below), to
connect "available", "add" and "Add to cart" so that when "Add to
cart" is
clicked struts can carry out the verification to compare "add" and
"available".

Look at the indexed attribute for the fields within the logic:iterate
tag body, i.e. use something like this:

<logic:iterate ...>
<html:text property="..." indexed="true"/>
</logic:iterate>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top