• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

populating jsp page with arraylist of beans

 
Ranch Hand
Posts: 30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend favoring JSTL standard tags for proprietary Struts tags when appropriate.
 
Brian Wheeler
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 24
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic