my dog learned polymorphism*
The moose likes Struts and the fly likes Hold Form Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Hold Form Data" Watch "Hold Form Data" New topic
Author

Hold Form Data

Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Hi,

I have a scenario where I have to get data from the database and show it in the listing format (Report). To achieve this I am getting data in the form of value objects, Holding that data in request scope and I am using <logic:iterate> to loop through the collection of valueobjects.

Below the listing I have a button called "Export" which should open a file save dialog box and enable user to save the report.

As I am holding data in the request scope, a new request will be started on click of Export button, I cannot access data from the Action class.

I don't want to get the data again from the database and I cannot hold data in session scope either.

Do Struts framework provide any functionality that I can make use of. How such scenario are handled in general.
Hope to see early replies.
Thank you very much in advance
Saritha
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Ah, the ever-popular scenario which boils down to "I want to store in session but I don't"

Here are the options:
Store data in session
Save data as hidden fields in jsp
Write the data to a file
Make another call to backend


A good workman is known by his tools.
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Agreed. Looks like you're going to have to bite the bullet and put some data in the session (which isn't really all that bad if you make sure to clean-up every now and then).
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Thank you,

Ur replies where helpful and appreciated. I guess I will go with hidden fields. So that I don't have to worry abt cleaning up session.

I have one more scenario. I have a search criteria form. The user would setup some search criteria and clicks search, a listing page is shown with search criteria on top of the listing. Now, in the search method of Action class I have to reset the criteria to the form class inorder to show the selected criteria in my lisitng. How can I persist criteria selected without resetting same data to same form.

Thank you
Saritha
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi saritha

I am not getting whats the reason to call reset methjod in ur action class to persist the selection criteria.........If u have the form bean attached to the search screen then that will be populated ............so there is no need to call reset method right??
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
I guess my post is confusing.
I am not calling reset method. I was thinking of reassigning search criteria values to the form again in the action.

Sreenath, your right. I don't have to call either reset method or reassign form values. I did not implement above scenario practially. It was prepration for my coding.

I apologize for this. From now on, I will first implement and then post my queries.

Thank you
Saritha
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Hi,

One more question on struts framework
I have a menu from where I will click on a hyperlink which takes me to listing page. In my listing page I have checkbox before each record and delete button in the bottom of the listing.

Now, when user selects records from the listing and clicks delete button, I have to go and delete those records from the database.

on error, I have to show same listing with error message on top when I say return (mapping.getInputForward()); it is taking me to menu page. How can i get back to my listing page without getting whole data from the database again?

or it is compulsory to get whole records from database in both success and error conditions.

My question is why return (mapping.getInputForward()); is taking me to menu page

Please help me out.
Thank you
Saritha
 
GeeCON Prague 2014
 
subject: Hold Form Data