File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes logic:iterate with Textarea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:iterate with Textarea" Watch "logic:iterate with Textarea" New topic

logic:iterate with Textarea

Mittal Mistry

Joined: May 17, 2006
Posts: 3
I want to geerate teatarea dynamicaly. For that i take ArrayList of solution Textarea...i have written following code for that..

<jsp:useBean id="solution" class="java.util.ArrayList" scope="page" />

<logic:iterate name="solution" id="addSolution">
<td><html:textarea property="solution" name="addSolution" indexed="true"/></td>

Jsp is not giving displaying other control..but this textarea is not getting displayed..its not going in iterate loop..What can be a problem

Please help me if any one know abt it

Thankx and regards
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
First of all, you have to write some code to populate this ArrayList before executing the code in the JSP. Otherwise, the list will always be empty and the <logic:iterate> tag will have nothing to iterate over.

Secondly, if you want to have inputs on your form that are used by Struts to automatically populate a bean, the properties you wish to populate must be in the ActionForm bean associated with that page's action. You can't just put an array of objects into some scope and expect Struts to populate them when the form is submitted.

You would need to define the solution List as a property on your ActionForm bean and then define a getter/setter pair for the whole list, and another getter/setter pair to retrieve or set a single element of the list given it's index.

this link will give you some good information about using indexed properties in forms.

Consultant, Sima Solutions
I agree. Here's the link:
subject: logic:iterate with Textarea
jQuery in Action, 3rd edition