Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

struts

 
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
 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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...
 
Author
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.
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic