Results 1 to 3 of 3

Thread: How to pass data from onSubmit to referenceData?

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Default How to pass data from onSubmit to referenceData?

    Hi all,
    I have some data that I want to pass from the onSubmit method of my MVC Controller (which 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.

  2. #2
    Join Date
    Oct 2008
    Location
    Delhi, India
    Posts
    163

    Default

    You can check if the form has been submitted or not by calling the isFormSubmission() method. If it has been submitted, don't call referenceData(). However this requires that you set your form as a session form.

  3. #3
    Join Date
    Dec 2008
    Posts
    4

    Default

    Hi all,
    I figured out the solution to this and it was quiet simple. :jumpingjoy:

    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)...

    Code:
    mav = new ModelAndView(successView);
    return mav;
    But now I just did the following...
    Code:
    else if (pagingRequest != null && pagingRequest.length() > 0)
    		{ // if  paging action go back
    			return showForm(request,response,errors);
    		
    		}
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •