aspose file tools*
The moose likes Struts and the fly likes populating jsp page with arraylist of beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "populating jsp page with arraylist of beans" Watch "populating jsp page with arraylist of beans" New topic
Author

populating jsp page with arraylist of beans

Brian Wheeler
Ranch Hand

Joined: Dec 06, 2010
Posts: 30
Hello World,

I'm new to Struts and have a question maybe someone can help me understand. I'm working on a project where I'm trying to replace all the java scriplets in a JSP page with struts tag libraries.

One of the scriplets I want to convert involves a bean and action class. The action class is where a session arraylist of bean is set and implemented. Currently there are scriplets that uses session variables to populate the jsp page.

With my understanding of tag libs now, my approach would be to use logic:iterate tag to read through the arraylist and then use a bean:write tag nested inside the logic:iterate tag to populate the page.

I would liketo hear some feed back on this approach or if you have another approach.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

I would recommend favoring JSTL standard tags for proprietary Struts tags when appropriate.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brian Wheeler
Ranch Hand

Joined: Dec 06, 2010
Posts: 30
Bear Bibeault wrote:I would recommend favoring JSTL standard tags for proprietary Struts tags when appropriate.


I'm using jstl 1.1 tag libraries but after deploying my project I found out today that I'm limited to struts tags and jstl 1.0 because servlet is 2.3. Not much of a problem except I am using the jstl 1.1 function tags which 1.0 dont have. Is there a struts tag or jstl 1.0 tag similar to the jstl 1.1 fn:substring tag? Searching through this forum I can probably get away by just doing the substring in the action or bean class. Would like to hear more opinions.
Ganesh Gore
Greenhorn

Joined: Jan 03, 2011
Posts: 24

Hi,


Following code i had used to poplulate a combo box using a collection of beans may be this can help you.

Here struts-html tag has been used. Include the struts-html.jar to your project and following lint to your jsp page.
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>



In the code property="pvob" is name specified in form the bean for the combo box . Using its getter and setter methods (setPvob,getPvob) the select value of combobox can be accessed in action class.
eg:

Here name="trileadActionForm" is the name of form bean as specified in struts-config.xml.
property="pvobList" is name of collection as specified in form bean.
eg:

Here value="pvobName" is member of bean class whose object are contained in the arraylist.
eg:
public class PVOB {
String pvobName;

public String getPvobName() {
return pvobName;
}
public void setPvobName(String pvobName) {
this.pvobName = pvobName;
}
}
For properties in form bean provide a getter setter method.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: populating jsp page with arraylist of beans