struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manisha Sathe <manisha_msa...@yahoo.com>
Subject How to display vectors / beans data inside JSP using tags?
Date Thu, 30 Dec 2004 08:56:36 GMT
I want to display bean data on JSP which has vectors as one element.
 
I have advertisement with multiple headers (max 3) and each headers has multiple details llines.
 
My Main Advertisement databean 'AdvertFormDataBean' consists of the date of advertisement
and arraylist for headers. I know there can be max only 3 headers or less.I created another
Bean AdvertDtlsDataBean - which consists of my detail lines. 

Now what i am doing in my Action form  -> creating multiple advertisements. Currently all
are manual entries, i am goign to put logic inside later.
1)AdvertFormDataBean object. Putting adv date. 
2)Separately creating vector array of AdvertDtlsDataBean objects for each header. 
3)Assigning these vectors to arraylist of headers of AdvertFormDataBean 

It seems assignment is done properly

On frontend want to use JSP/JSTL to display it - but here bit confused


public class AdvertFormDataBean { 	private String advDate;	private ArrayList arrAdvertHdrs
= new ArrayList(3);.....} public class AdvertDtlsDataBean { 	private String hdrdesc;	private
String leaguename;	private String hometeamname;.....}public final class preAdvertActionHandler
extends Action{ 			for (int i=1; i<=iAdvCnt; i++)			{				String AdvnewdateString = new
SimpleDateFormat ("yyyy-dd-mm").format(cal.getTime());				AdvertFormDataBean advertFormDataBean
= new AdvertFormDataBean(); 				advertFormDataBean.setAdvDate(AdvnewdateString);				ArrayList
hdrlist = new ArrayList(3); 				Vector advertdtls0 = new Vector(3); 				AdvertDtlsDataBean
advertdtlsDataBean0 = new AdvertDtlsDataBean();				advertdtlsDataBean0.setHdrdesc("hdr desc
0");				advertdtlsDataBean0.setLeaguename("hdr desc 0 - leaguename 0");				AdvertDtlsDataBean
advertdtlsDataBean1 = new AdvertDtlsDataBean();				advertdtlsDataBean1.setHdrdesc("hdr desc
1");				advertdtlsDataBean1.setLeaguename("hdr desc 1 - leaguename 1"); 	
			advertdtls0.add(0, advertdtlsDataBean0);				advertdtls0.add(1, advertdtlsDataBean1);		
	hdrlist.add(0,advertdtls0);   				AdvertDtlsDataBean advertdtlsDataBean2 = new AdvertDtlsDataBean();
			advertdtlsDataBean2.setHdrdesc("hdr desc 2");				advertdtlsDataBean2.setLeaguename("hdr
desc 2 - leaguename 2"); 				Vector advertdtls1 = new Vector(5);				advertdtls1.add(0, advertdtlsDataBean2);
			hdrlist.add(1,advertdtls1); 				advertFormDataBean.setArrAdvertHdrs(hdrlist); 				arrAdvertFormDataBean.add(advertFormDataBean);
			cal.add(Calendar.DATE,1);			}   request.setAttribute("arradvertformdatabean", arrAdvertFormDataBean);
 


------------------------------
My JSP looks like below


<%@ taglib uri="struts/bean" prefix="bean" %><%@ taglib uri="struts/html" prefix="html"
%><%@ taglib uri="jstl/c" prefix="c" %><html><head><title>Sports
Betting Advertisement Form</title><link href="<html:rewrite page="/jsps/sbcs.css"
/>" rel="stylesheet" type="text/css"></head><body> <c:forEach var="arradvertformdatabean"
items="${arradvertformdatabean}">	<c:out value="${arradvertformdatabean.advDate}"/><br>
		<c:out value="${arradvertformdatabean.arrAdvertHdrs[0]}"/>	<br>	<c:out value="${arradvertformdatabean.arrAdvertHdrs[1]}"/>
<br>	<c:out value="${arradvertformdatabean.arrAdvertHdrs[2]}"/>	<br> </c:forEach>
   </body></html>

ok, here i want to display all vector details but do not know how to do it

Pls guide me.

regards

Manisha

 

 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message