This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts

 
daffny nila
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have getList() in my bean so I have

<bean:write name="formBean" property="list"/>

but i have to display the size of the list in my jsp page. how to get size from this?

I am new to struts. anybody can explain this to me?

thanks
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Daffny, welcome to javaranch.

Daffny please Use A Meaningful Subject Line when you start a topic. What is this list exactly which getList method returns. Is it a java.util.List?? The size property of List interface is not java bean compliant, so I don't think you can access it using EL. In struts 2 you can access it using OGNL but I don't know about struts 1...
 
daffny nila
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply and suggestion, i will use meaningful subject lines hereafter.

yes its java list. anything i can do in action class? i try to get thro' jsp code

<%
int i=formBean.getList().size();
%>

and this doesnt work, saying can not find formBean in any scope.

its urgent ps help.

thanks
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a way of doing this in scriptlet, but I think it would be better if you set the size of the list as an attribute in request scope in the action (actually I don't know if this is better). Then you can easily access it in the JSP. The scriptlet solution is that you get the form bean which is stored as an attribute in request scope (or session scope as per declaration in your struts-config.xml). Then you can call the getList().size() on it...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can edit your post to correct the title.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic