• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

logic:iterate with Textarea

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic