Announcement Announcement Module
No announcement yet.
Populating drop-down lists Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Populating drop-down lists

    Hi all!

    I have a class that extends SimpleFormController. In this formView I have 3 drop-down lists. I have implemented referenceData(request) to populate these drop-down lists.

    When the user posts the form I want the user to see the changes appear in the form so I have configured formView = successView, but when the user posts the drop-down lists are not populated. The url contains a parameter (myapp/mypage?parameter=[variable]) so I cannot do a redirect based on the succcessView to make sure referenceData(request) is called again.

    What would be the prefferred way of doing this? I could override the onSubmit(request, response, command, errors) and build the redirect url myself, but then I would missout on the configuration of the successView.

    This functionallity will be used in multiple forms in my app, and I cannot make changes to the url patterns used.



  • #2
    in your controller implemnt this method:

    	protected Map referenceData(HttpServletRequest request) throws Exception {
    		Map model = new HashMap();
    		model.put("countryList", countryManager
    				.getCountries(new Country()));
    		return model;
    Where "countryList" will be used in your JSP code

    Look here


    • #3
      Hi radone!

      I have already implemented the referenceData method.

      The problem is that referenceData is only called when a GET request is issued. In my case I issue a POST and use the same view for formView and successView, and I cannot configure the successView to be a Url and redirect to it after a succesful submit because of changing parameters.

      My question is what is the easiest way to add these to the request myself, without having to write the code twice, or would it be easier to create the redirect url myself inside the onSubmit() method.


      • #4
        I am using post method in my example too.


        • #5
          You can call the referenceData method in your onSubmit method, e.g.


          • #6
            Sorry radone!

            I only looked at the line where you forwarded to getSuccessView(), not your "update" part.

            Thanx for your help