This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Help regarding logic:iterate tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help regarding logic:iterate tag" Watch "Help regarding logic:iterate tag" New topic
Author

Help regarding logic:iterate tag

Sana Jay
Greenhorn

Joined: Feb 03, 2004
Posts: 26
hello,
I am using logic:iterate to get multiple input parameters.The logic:iterator tag in my jsp is as shown.

<logic:iterate name="rowsForm" property="iterator" id="row" type="test.RowForm">
</logic:iterate>
In my Form.
i have get and set property for the String[] RowId and String[] RowProperty
The error is
Cannot create iterator for this collection
So wat should be the getter and setter for iterator.
Can anyone plz explain this.
Thanks in advance
Sana
Sana Jay
Greenhorn

Joined: Feb 03, 2004
Posts: 26
hello,
Thanks but i just found out the answer for my question.Iterator iterates through a 'collection' of my property.
But i am facing another problem....
In my Jsp page i am unable to get a textfield initially.Only after submitting the form the textfield is seen populated with the values which i have populated manually.
I am unable to figure out the reasons for this.
Can anyone plz guide.
Thanks,
Sana
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

There could be a number of reasons.
You say the textfields should have pre-populated values - where are you setting these values in your code???
My first hunch would be to say that your form is resetting your values to null.
How 'bout some code?


A good workman is known by his tools.
Sana Jay
Greenhorn

Joined: Feb 03, 2004
Posts: 26
hello,
The jsp code is as follows.
<table>
<tr>
<th>id</th>
<th>property</th>
</tr>
<logic:iterate name="rowsForm" property="iterator" id="row" type="rowtest.RowForm">
<tr>
<td>
<bean:write name="row" property="rowId" />
<html:hidden name="row" property="rowId" />
</td>
<td>
<html:text name="row" property="rowProperty" />
</td>
</tr>
</logic:iterate>
</table>
<html:submit property="Submit">Submit</html:submit>

I am not getting the textfield(of rowproperty) displayed in the jsp page initially.Is it becos the iterator iterates only when the collection is not null.
Only the <th>id and <th>rowproperty is displayed.
But no textfield for the rowproperty.
Only when submitted the textfield is displayed with the values assigned in the form to the properties.
How to go abt this.

Thanks
Sana
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

The iterator can't iterate if the collection is null, or even if the collection isn't null but holds no Objects. There's nothing to iterate through in that case.
It says "for each object found in the collection, do what's between the tags". If no objects are found, you'll never see what is between the tags.
Sana Jay
Greenhorn

Joined: Feb 03, 2004
Posts: 26
hello,
Thanks,,I have got it to work.I just had to intialize the property in the form.
regards,
Sana
 
wood burning stoves
 
subject: Help regarding logic:iterate tag
 
Similar Threads
STRUTS: Iterating over a collection of ActionErrors
on logic:iterate tag
problem with logic:iterate
From an input-field into a form
pass results of a struts logic tag to a java method?