Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

logic:iterate with Textarea

 
Mittal Mistry
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" />

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

Jsp is not giving error..it 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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic