All,
I would like some advice on how to handle business exceptions thrown as a result of an html form submission.
Previously in SWF 1.x I would declare a method to process the form submission that would have a return type of Event. If the method call succeeded it would return success() and the flow would transition as required. If it failed an error message would be created and added to the errors object in the RequestContext, the method would return error() and the flow would transition back to the calling page .
The below code snippets shows an example of the <action-state> that defines the method a call and the transitions and the method called from the action.
Code:<action-state> <action bean="searchBean" method="findText"/> <transition on="success" to="results"/> <transition on="error" to="search"/> </action-state>
I will crack open the 1.x source and have a look at what is going on to see how I can replicate this in SWF 2.0.x but in the mean time would be very interested to know if there is an established "pattern" for handling this situation in SWF 2.0.xCode:public Event findText(RequestContext ctx) String text = null; try { text = searchForText(); } catch(AbcNotFoundException e) { getFormErrors(ctx).reject("text.error.key", "No text found default message"); return error(); } ctx.getFlashScope().put("text", text); return success(); }
You help greatly appreciated.


Reply With Quote

