File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts " Watch "struts " New topic
Author

struts

daffny nila
Greenhorn

Joined: Jan 31, 2010
Posts: 9
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

Joined: Aug 03, 2008
Posts: 9280
    
  17

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


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
daffny nila
Greenhorn

Joined: Jan 31, 2010
Posts: 9
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

Joined: Aug 03, 2008
Posts: 9280
    
  17

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

Joined: Sep 29, 2008
Posts: 12617

You can edit your post to correct the title.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts
 
Similar Threads
Accessing formbean
Iterator in Struts 1
How to increase number of parellel ajax hits from same user!!
Collections.copy method for lists ? how it works
Define size to h:dataTable