Announcement Announcement Module
Collapse
No announcement yet.
handling exception in formBackingObject Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • handling exception in formBackingObject

    what is the proper way to handle an exception in formBackingObject of my subclass of SimpleFormController?

    currently I retrieve some data to be displayed in this method and the data layer may throw an exception. I would like to catch it and then display it on a page. i.e.:


    protected Object formBackingObject(HttpServletRequest request) throws Exception {

    String orderId = RequestUtils.getRequiredStringParameter(request, "orderId");

    try {
    return (Order)service.getOrder(orderId);
    } catch (LockedException e) {
    //what to do now?
    }
    }

  • #2
    ModelAndViewDefiningException

    The only thing you can really do is eat the exception (bad) or throw a new exception. You might want to take a look at org.springframework.web.servlet.ModelAndViewDefini ngException. This allows to to specify a model and view to "handle" your exception.

    Comment


    • #3
      Re: ModelAndViewDefiningException

      I think this will help me a lot. Thank you.

      Comment

      Working...
      X