You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/06/24 22:38:05 UTC

DO NOT REPLY [Bug 29792] New: - Action method saveErrors lose messages on chained actions

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29792>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29792

Action method saveErrors lose messages on chained actions

           Summary: Action method saveErrors lose messages on chained
                    actions
           Product: Struts
           Version: Unknown
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Controller
        AssignedTo: dev@struts.apache.org
        ReportedBy: dominic_veit@centraltechnology.net


The standard way to add Errors to the request is the method Action.saveErrors()

The problem is, if you chain 2 actions together, by having one action forward 
to another action, the saveErrors() in the second action will wipe out any 
errors placed by the first action.  

We have worked around this by changing from the standard examples and doing 
this code

ActionErrors errors =  (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
if (errors == null){
	errors = new ActionErrors();
}

Then we can add errors like normal and , no matter how many actions are 
chained, all errors make it through to the JSP!!!!

We feel this is not a good practice though, because we have to know how struts 
implements the saveErrors() method (Globals.ERROR_KEY), it creates a 
dependency on the Globals class, and if you change this in a later release, 
our code breaks.  

We feel a better solution would be to change the implementation of saveErrors
() to add errors to the existing request attribute, if one exists, instead of 
overwriting.  

Another alternative would be to add a getActionErrors(HttpServletRequest) 
method to Action which would return the current action errors, or a new 
ActionErrors() if none exist.  This may be a better solution, if you fear 
changing the implementation of saveErrors().

The saveMessages() method has the same "problem".  

Any comments you have would be appreciated.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org