aspose file tools*
The moose likes Struts and the fly likes bean:write ??????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:write ???????" Watch "bean:write ???????" New topic
Author

bean:write ???????

rahul karwal
Ranch Hand

Joined: Oct 26, 2001
Posts: 73
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

Joined: May 29, 2003
Posts: 1258


... 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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
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

Joined: Feb 05, 2003
Posts: 4727

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 ]

A good workman is known by his tools.
rahul karwal
Ranch Hand

Joined: Oct 26, 2001
Posts: 73
thanks use the John Smith way and it worked.
thanks,
aziz dhanani

heres what i did
<logic:iterate id="currentUser" name="searchResult" type="AdminSearchBean">
 
Don't get me started about those stupid light bulbs.
 
subject: bean:write ???????