View Single Post
  #2 (permalink)  
Old 04-11-2007, 03:10 AM
pegitha pegitha is offline
Member
 
Join Date: Apr 2007
Location: Indiana
Posts: 84
pegitha is on a distinguished road
Send a message via Skype™ to pegitha
Here is how I normally handle something like this:
Code:
public ActionForward getWidgets(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); ActionForward forward = new ActionForward(); try { List widgets=WidgetManager.getWidgets(); forward = mapping.findForward("gotthem"); } catch (NoWidgetsFoundException e) { errors.add("noWidgetsLeftError", new ActionMessage("error.noWidgetsLeftError")); saveErrors(request, errors); } return (forward); }
My WidgetManager.getWidgets() throws a NoWidgetsFoundException. That is caught in the Action and then you create a new ActionMessage. The message that is going to be displayed is still in the ApplicationResource.properties file, just like the errors you collect in the Form.validate() method.
Reply With Quote