Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bean:write ???????

 
rahul karwal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an ArrayList of objects (meaning i have refernce to the objects which is a Bean class say SearchBean), and i have the ArrayList in the request object, can i use bean :write to access the GetMethod of my SearchBean? here is the snippet of the code: -
request.setAttribute("searchResult",searchList); --- my ArrayList.

<logic:iterate id="currentUser" name="searchResult">
<%SearchBean search = (SearchBean)currentUser;%>
<tr >
<td><%out.print(search.getUserName());%></td>
<td><%out.print(search.getEmail());%></td>
<td><html:link page="" >Edit</html:link></td>
<td><html:link page="">Delete </html:link></td>
</tr>
</logic:iterate>
i want to replace the scriplet code with any of the Struts or JSP tags, is it possible, can anyone give me a small example how this can be done?

thanks
aziz dhanani.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


... or something close to that. I'm not sure how nested variables like currentUser are referenced. Check out the Struts website for documentation .. here's a start.
 
John Smith
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of your dynamic cast use a bean efine on the variable exposed by the iterate tag, your bean:write tags will then be able to find the getter methods and such
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSTL equivalent requires no casting:
<c:forEach var="currentUser" items="searchResult">
<tr>
<td><cut value="${currentUser.userName}"/></td>
<td><cut value="${currentUser.email}"/></td>
...
</tr>
</c:forEach>

Just evangelizing.
[ December 10, 2004: Message edited by: Marc Peabody ]
 
rahul karwal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks use the John Smith way and it worked.
thanks,
aziz dhanani

heres what i did
<logic:iterate id="currentUser" name="searchResult" type="AdminSearchBean">
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic