aspose file tools*
The moose likes Other Application Frameworks and the fly likes How to pass data from onSubmit to referenceData? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "How to pass data from onSubmit to referenceData?" Watch "How to pass data from onSubmit to referenceData?" New topic
Author

How to pass data from onSubmit to referenceData?

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
Hi all,
I have some data that I want to pass from the onSubmit method of my MVC Controller (extends SimpleFormController) to the referenceData method of that controller. How can I go about doing this?


It is not as simple as putting it as a request attribute because when the code comes to the referenceData a new request is created.

If you are wondering why I need to do this, it is for pagination. In the referenceData method is where I get the default list of rows from the db. But once the user pages I do a form submit on my JSP and get the next page in my onSubmit. The problem now is that when the code comes back to the referenceData after that submit it is overwritting the "paged" list with the original list.


Thanks in advance for any help.
Ken Krebs
Ranch Hand

Joined: Nov 27, 2002
Posts: 451
The referenceData method is called by the framework before your onSubmit method is called, not after.

The workfow is well documented in the Javadoc for AbstractFormController.


kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
What I am doing is that I am doing a form submit to the same Controller so it should call the onSubmit first. I debugged the code and as I stepped through it I saw that onSubmit was being called first.

Any other suggestions. Thanks again.
Ken Krebs
Ranch Hand

Joined: Nov 27, 2002
Posts: 451
I don't think that referenceData() is of any help to you here. If you look at the javadoc, it is called before the initial rendering of the View before the form is submitted. Generally, this is your opportunity to put things in the Model (request attributes) that your form needs when it is rendered before it is submitted. If you want to pass something to another Controller, you can put it in the Model or if you're redirecting to the other Controller you can put it in the session.
Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
So if your JSP had a list of data (like a summary screen), in which method would you populate this list? (sounds like a good interview question)
Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
Hi all,
I figured out the solution to this and it was quiet simple.

Before in my onSubmit method I was creating a new ModelView and doing a redirect to my successview (that is why I was losing the request)...



But now I just did the following...


This fixed it. Now I have my request parameters in my referenceData method and I get the correct data for each page.

Thanks all for any help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass data from onSubmit to referenceData?