saveErrors...
I was looking at the code for Action.saveErrors(...) and was think this is a little inflexible when it comes to error and message management: protected void saveErrors(HttpServletRequest request, ActionMessages errors) { // Remove any error messages attribute if none are required if ((errors == null) || errors.isEmpty()) { request.removeAttribute(Globals.ERROR_KEY); return; } // Save the error messages we need request.setAttribute(Globals.ERROR_KEY, errors); } If I have errors occur in different locations, rather than returning ActionMessages objects and having to merge them myself prior to calling saveErrors or saveMessages, why not have this be more like addError or addMessage at the action level so that the user doesn't need to maintain the ActionMessages object themselves? As well they can call saveError almost anywhere in the code without overwriting the existing errors object, which is saveErrors existing behavior. ... saveError(request,foo, new ActionMessage(foo.bar)); ... protected void saveError(HttpServletRequest request, String key, ActionMessage error) { ActionMessages errors = (ActionMessages) request.removeAttribute(Globals.ERROR_KEY); // Remove any error messages attribute if none are required if ((errors == null)) { errors = new ActionMessages(); } errors.add(key, error); request.setAttribute(Globals.ERROR_KEY, errors); } -Mark Diggory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Please IGNORE, This post is to the wrong list (was Re: saveErrors...)
Mark R. Diggory wrote: I was looking at the code for Action.saveErrors(...) and was think this is a little inflexible when it comes to error and message management: protected void saveErrors(HttpServletRequest request, ActionMessages errors) { // Remove any error messages attribute if none are required if ((errors == null) || errors.isEmpty()) { request.removeAttribute(Globals.ERROR_KEY); return; } // Save the error messages we need request.setAttribute(Globals.ERROR_KEY, errors); } If I have errors occur in different locations, rather than returning ActionMessages objects and having to merge them myself prior to calling saveErrors or saveMessages, why not have this be more like addError or addMessage at the action level so that the user doesn't need to maintain the ActionMessages object themselves? As well they can call saveError almost anywhere in the code without overwriting the existing errors object, which is saveErrors existing behavior. ... saveError(request,foo, new ActionMessage(foo.bar)); ... protected void saveError(HttpServletRequest request, String key, ActionMessage error) { ActionMessages errors = (ActionMessages) request.removeAttribute(Globals.ERROR_KEY); // Remove any error messages attribute if none are required if ((errors == null)) { errors = new ActionMessages(); } errors.add(key, error); request.setAttribute(Globals.ERROR_KEY, errors); } -Mark Diggory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]