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=20750>.
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=20750

RequestUtils.retrieveMessageResources (really an RC2 bug)

           Summary: RequestUtils.retrieveMessageResources (really an RC2
                    bug)
           Product: Struts
           Version: 1.1 RC1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Utilities
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The new retrieveMessageResources method now checks all scopes looking for the 
MessageResources bundle.  In my application, I unwittingly used the same name 
for my application specific beans and the message resource bundle.  This is 
because I used the same naming convention.  For example, I have a "Person" 
module.  I created a "person" bundle and often pass around "person" beans.  In 
RC1 this does not conflict because it searches only the application scope if a 
bundle name is provided.  My application specific beans are using Request 
Scope.  Now I get a ClassCastException.  

Since my application is only 4 weeks from going into production (fingers 
crossed), and I have been doing this since beta1, I consider this a serious 
problem(if only for me).  I realize now, to my dismay, that I should have 
considered a better naming convention, etc.  However using 
bundle="messages.person" or name="biz.threemv.claris.person.Person" or others 
is just not as appealing when writing over 100 jsps.  

I suggest that the original behaviour of checking Application Scope first be 
utilized.  This will ensure that all struts developers who may have unwittingly 
done the same thing, do not have immediate conversion issues before using RC2 
or the final release.

        private static MessageResources retrieveMessageResources(
                PageContext pageContext,
                String bundle)
                throws JspException {
            
                MessageResources resources = null;

                if (bundle == null) {
                        bundle = Globals.MESSAGES_KEY;
                }

                if (resources == null) {
                        resources =
                                (MessageResources) pageContext.getAttribute(
                                        bundle,
                                        PageContext.APPLICATION_SCOPE);
                }
                if (resources == null) {
                        resources = 
                                (MessageResources) pageContext.getAttribute(
                                        bundle,
                                        PageContext.REQUEST_SCOPE);
                }

                if (resources == null) {
                        resources =
                                (MessageResources) pageContext.getAttribute(
                                        bundle,
                                        PageContext.PAGE_SCOPE);
                }

                if (resources == null) {
                        JspException e =
                                new JspException(messages.getMessage
("message.bundle", bundle));
                        saveException(pageContext, e);
                        throw e;
                }

                return resources;
        }

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

Reply via email to