Results 1 to 9 of 9

Thread: best controller for search page

  1. #1
    Join Date
    Sep 2005
    Posts
    4

    Default best controller for search page

    Hi-

    I am designing a page that will have a top panel for search criteria (lists, dates, etc) and then a panel below would display the results in a table. Simple. However, I'm trying to use SimpleFormController with referenceData to populate the select lists, but I need the "success" screen to be the same as the form screen due to a user requirement. The way the controller is setup though when I try to populate the lists it can't find the list beans since referenceData() was not called again. I hope this makes sense. Can someone suggest the best design to allow for binding and validation but to have the post-submit page to have the same form input objects?

    Thanks!

  2. #2
    Join Date
    Sep 2005
    Posts
    4

    Default redirect

    I see there is something similar posted earlier re redirect view. Does this seem the most sensible? When I tried using this, though, because my model contains a list of search results, it bombs trying to convert it to HTTP query parameters.

    Does anyone have experience doing a page like this that can offer help?

    Thanks!

  3. #3

    Default

    i have the same problem being the form view is the same as my sucess view, and i need to have a list populated too.

    although i have not yet found a solution, one suggested using RedirectView in AbstractFormController, however, i prefer if it would be a solution available using SimpleFormController.

    keeps me posted if you find a solution.

    thanks.

  4. #4
    Join Date
    Jul 2005
    Location
    COIMBATORE-INDIA
    Posts
    110

    Default

    Hai

    I am using refrence data in my simple form controller and in the servlet file i setted the successview to the same form,Its working fine for me.

    Can u post u r scenario briefly

    Thanks
    aniesh U.K

  5. #5
    Join Date
    Sep 2005
    Posts
    4

    Default code info

    I too am using SimpleFormController as well as using the referenceData to populate lists. I set the form and success view to the same view. When the page first loads it is fine (since reference data is called when requesting a form), but when i submit the form it goes to the same page as expected, but it does not know what the list beans are since referenceData was not rerun. When not binding it just causes empty lists, when trying to bind it complains about not being able to find a bean by that name.

  6. #6
    Join Date
    Jul 2005
    Location
    COIMBATORE-INDIA
    Posts
    110

    Default

    Hai spring

    Hope u r problem is that refrenceData is not called after the form submission.Am i right.R u placing the map(model) of refrence inside a condition?.Can post u r code.

    Thanks
    aniesh U.K

  7. #7
    Join Date
    Sep 2005
    Posts
    4

    Default code

    My code for referenceData is very simple:

    Code:
    protected Map referenceData(HttpServletRequest request) throws Exception {
    		Map refData = new HashMap();
    		List cards = webDataManager.getCards();
    		refData.put("cards", cards);
    		return refData; 
    }
    But as I see in the documentation, this method is only called when retrieving a new form. The only time it is called on form submission is if there are bindexceptions, and it goes back to the form view.

    I tried usign RedirectView, but because I have a bean representing search results in my model, it bombs trying to convert it to HTTP query params.

    As I see it, my options to use SimpleFormController are to use a SessionForm so the reference data (list data) is maintained, or to rework the flow so the submission results is a different page and require the user to return to a search screen.

    I have written it using AbstractController, but without the command backing object I would have to do all of my own binding and validation.

    Still appreciate any insight!

  8. #8
    Join Date
    May 2005
    Posts
    23

    Default

    all you should have to do is make a call to referenceData(...) from within the processFinish method before you return the ModelAndView object.

    also - realize that you don't have to work w/in the confines of the controllers provided by spring. i wrote a custom searching controller so that i could meet this type of requirement and handle paging requests.
    -jae

  9. #9
    Join Date
    Oct 2004
    Location
    Palmas-TO, Brazil
    Posts
    92

    Default

    in you onSubmit method you can do this:

    Code:
    Map model = new HashMap();
    
    model = errors.getModel();
    
    model.put("localidades", localManager.getLocalidades("TO"));//I have this in  the referenceData method too!
    
    model.put("localList", results);
    
    return new ModelAndView("popuplist/localPopList", model);
    Gilberto

Similar Threads

  1. View to forward to another controller?
    By justinp in forum Web
    Replies: 6
    Last Post: Apr 2nd, 2010, 01:53 PM
  2. Replies: 7
    Last Post: Jan 27th, 2006, 08:17 AM
  3. Replies: 0
    Last Post: Jun 10th, 2005, 08:22 AM
  4. How to include a controller from jsp page
    By fmourioux in forum Web
    Replies: 1
    Last Post: Feb 13th, 2005, 08:28 AM
  5. Page flow controller
    By klr8 in forum Web
    Replies: 9
    Last Post: Nov 16th, 2004, 03:49 PM

Posting Permissions

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