• Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts : Size of the Bean to be iterated  RSS feed

 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In my JSP, i do an iteration on a bean
<logic:iterate id="newObj" name="newObjList">
The "newObj" is just a Vector created from a "ObjList" class which is a wrapper around the Vector class.
I tried to add a getSize() method in it in order to display the size of the bean to be iterated in the JSP. Something like
<bean:write name="newObj" property="size"/>
It doesnt work and i've got the following message instead :
javax.servlet.jsp.JspException: No getter method for property size of bean newObj
What's wrong ?
Why isn't my getSize() method used ??
Thanx in advance
 
Tiago Fernandez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Franck,
The <bean:write/> just write the property of the object using the respective getter method. To do what you want, you have to use <bean:size/>, then you will get the size of the bean.
Try something like this:
<logic:iterate id="newObj" name="newObjList">
...
<bean:size id="size" name="newObj" />
<bean:write name="size" />
...
</logic:iterate>
 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So easy !
I tried another solution :
<..>
<jsp:useBean id="myList" scope="request" class="java.util.Vector"/>
<%int objNumber=myList.size();%>
Number of Objects returned = <%=objNumber%>
<..>
Actually, it works but i really prefer your solution !
Thanx Tiago !!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!