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

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12344

Seems like you can only save ActionErrors in request scope...

           Summary: Seems like you can only save ActionErrors in request
                    scope...
           Product: Struts
           Version: 1.1 Beta 2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Utilities
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


at least if you want to display your errors using <html:errors/>.  this is 
because the ErrorsTag retrieves the ActionErrors object using 
RequestUtils.getActionErrors(PageContext, String), which retrieves the stored 
ActionErrors via:

Object value = pageContext.getAttribute(paramName, PageContext.REQUEST_SCOPE);

i don't think this was a problem until declarative exception handling allowed 
you to specify a scope in which to store the ActionErrors object the 
ExceptionHandler created.  it just so happens i wanted to store my ActionErrors 
in session scope, and discovered that my errors stopped appearing on the page.  
(by the the way, RequestUtils.getActionMessages() has the same problem.)  there 
are two ways to fix this:

(1) just search all scopes using findAttribute() instead of getAttribute().  
here's the diff on RequestUtils for that:

Index: RequestUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-
struts/src/share/org/apache/struts/util/RequestUtils.java,v
retrieving revision 1.53
diff -b -c -r1.53 RequestUtils.java
*** RequestUtils.java   23 Aug 2002 02:37:12 -0000      1.53
--- RequestUtils.java   5 Sep 2002 19:38:24 -0000
***************
*** 1548,1554 ****
  
          ActionErrors errors = new ActionErrors();
  
!         Object value = pageContext.getAttribute(paramName, 
PageContext.REQUEST_SCOPE);
  
          try {
          if (value == null) {
--- 1548,1554 ----
  
          ActionErrors errors = new ActionErrors();
  
!         Object value = pageContext.findAttribute(paramName);
  
          try {
          if (value == null) {


(2)  you could change method signature to accept a scope.  this would require 
quite a few more changes in RequestUtils and ErrorsTag.  basically, you'd have 
to add a scope attribute to ErrorsTag, then pass it to RequestUtils.getErrorsTag
().  If you want to pursue this option, let me know and i'll send a diff for it 
as well.

(3) ok, so i guess there is one more option, and that is to remove the 
capability to store ActionErrors in the session as provided by the declarative 
exception handling.  hopefully you won't choose this option, since that would 
be somewhat limiting to me.

(WORK-AROUND) by the way, if you do for some reason find yourself storing an 
ActionErrors object in the session, and you want to access it via the errors 
tag, try the following code:

<%@ page import="org.apache.struts.action.Action"%>
<bean:define id="foo" toScope="request"
             name="<% Action.ERROR_KEY %>" scope="session"/>
<html:errors name="foo"/>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to