You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vikas Phonsa <VP...@suz.com> on 2006/09/08 18:27:18 UTC
Vector in FormBean
Hi Everybody,
I'm using Struts 1.2.
On my JSP, I have two buttons: Generate Report and Print Report.
On the click of the "Generate Report", I need to generate a variable
length table on the JSP using data from a database and on the click of
"Print Report", I need to take the data in the report table and pop up a
new window with data in a printable format.
I can't make a new database call on click of "Print Report", so I have
to capture and use the data as it appears in the previous report table.
In the business rule class, I make a vector of java beans from the
database.
Right now, I can make the above functionality work, by the following two
ways (which don't seem very clean to me):
1. I store my Vector in session scope and iterate through it using
JSP scriptlets and remove it from the session scope once the "Print
Report" button is clicked. I don't want to do this as my vector can get
very large over time.
2. To avoid storing the Vector in the session, store it in the
request, so that I can make the table after "Generate Report", and also
store it in a cache (using EHCache) and restore it from the cache when
"Print Report" in clicked.
What I really would like to achieve is, store the Vector in a struts
Form Bean, iterate through it using struts tags on the JSP to make my
table and then on click of the "Print Report" button, get back the data
in Vector.
The beans in my vector have multiple fields.
I would appreciate any ideas to achieve this.
Thanks in advance.
Vikas