Announcement Announcement Module
Collapse
No announcement yet.
Search forms. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search forms.

    I've got a form that lists things. A user can search these things in which case a new page (the same jsp) is shown with the matches.

    I've implemented this by extending SimpleFormController but the result is this code:

    Code:
        public ModelAndView onSubmit(Object command)
        {
            Map myModel = new HashMap();
    
            // do the search.
    
            myModel.put("issues", bucket.getSplashes());
            myModel.put("search", search);
            return new ModelAndView(new RedirectView(getSuccessView()), myModel);
        }
    
        protected Object formBackingObject(HttpServletRequest request)
        {
            Map myModel = new HashMap();
    
            // do the search.
    
            myModel.put("issues", bucket.getSplashes());
            myModel.put("search", search);
            return myModel;
        }
    Which isn't very satisfactory.

    Is there a better way?

    Edward

  • #2
    you could use the same view for both formView and successView, just add the errors to the model.

    Code:
        protected ModelAndView onSubmit(HttpServletRequest request,
                HttpServletResponse response, Object command, BindException errors) throws Exception {
            Map myModel = new HashMap();
    
            // do the search.
    
            myModel.put("issues", bucket.getSplashes());
            myModel.addAllObjects(errors.getModel());
            return new ModelAndView(getSuccessView(), myModel); 
        }
    Gordon

    Comment

    Working...
    X