Announcement Announcement Module
No announcement yet.
How to direct users based on model object values? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to direct users based on model object values?

    Here's my scenario. Our site has a page that shows all off the service contracts you currently have with the company. If you don't have any contracts, we'd like to display a different page that tells you how great the service contracts are and how you should buy one.

    Currently, I'm just doing an if statement in showForm. Something along the lines of

    protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception {
            ContractList contractList = (ContractList) errors.getModel().get(getCommandName());        
            if (contractList.getContracts() == null) {
                return new ModelAndView("buyContracts");
            return super.showForm(request, response, errors);
    But it seems strange (yucky even) to be getting the command object via the BindException. Is there a better way?