PDA

View Full Version : handling exception in formBackingObject


deanholdren
08-13-2004, 10:05 AM
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?
}
}

jmakeig
08-13-2004, 11:13 AM
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.

deanholdren
08-13-2004, 11:50 AM
I think this will help me a lot. Thank you.