You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Oliver <ol...@sourceonenet.com> on 2005/04/06 20:36:03 UTC

message-resources null="false" returnNull=true

I am trying to debug why I cannot get ActionMessages to display.

I have set my struts-config.xml as follows:

<message-resources key="AJDocManResources"
  null="false" parameter="AJDocManResources"/>

AJDocManResources.properties is located in:

/WEB-INF/classes/AJDocManResources.properties

My log shows:

656   INFO  [main] util.PropertyMessageResources - Initializing,
config='AJDocManResources', returnNull=true

it appears the Message Resources file is loading but I cannot get
anything to display, it throws no exceptions and no ???null???? like
messages.  

Shouldn't returnNull=false with the null="false" in the
struts-config.xml???

Michael Oliver
Alarius Systems LLC
3325 N. Nellis Blvd, #1
Las Vegas, NV 89115
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com

-----Original Message-----
From: Michael Oliver [mailto:oliverm@sourceonenet.com] 
Sent: Wednesday, April 06, 2005 9:12 AM
To: 'Struts Users Mailing List'
Subject: RE: Html:messages vs html:errors

Still not displaying messages, here is what I have so far.

struts-config.xml entry:

<snip>
...<controller/>
 <message-resources id="ApplicationResources" key="ApplicationResources"
  null="false" parameter="ApplicationResources"/>
 <plug-in className="org.apache.struts.tiles.TilesPlugin">...

The ApplicationResources.properties file is located at 

/WEB-INF/classes/ApplicationResources.properties

it contains:

<snip>
... 
label.phone.number=Phone Number
label.welcome=Welcome back {0} {1}\!

message.body={0}

error.detail={0}
error.min.length=The input must be at least {0} characters in length.
error.max.length=The input cannot be longer than {0} characters in
length.
errors.required={0} is required.
errors.invalid={0} is invalid.
...
</snip>

I have log4j setup with 
log4j.logger.org.apache.struts=DEBUG,A1,A2

and on startup the log4j related output is:

656   DEBUG [main] action.ActionServlet - Initializing module path ''
message resources from 'ApplicationResources'
656   INFO  [main] util.PropertyMessageResources - Initializing,
config='ApplicationResources', returnNull=true

I have an Action that forwards to a jsp, the action execute has:

<snip>
...
if (uri.indexOf("Al") >= 0){
     	ActionMessages messages = new ActionMessages();
     	messages.add(ActionMessages.GLOBAL_MESSAGE, 
		new ActionMessage("message.body",retStatus));
      this.saveMessages(request, messages);
}
...
</snip>

where uri is a string variable of the resource the action is looking at,
and retStatus is a string that contains the status of the request.

The jsp has near the top if the body tile

<snip>
<tiles:put name="body" type="string">

<hr align="left" width="800" color="#000000" noshade>
<logic:messagesPresent message="true">
   <h3><font color="red">Messages:</font></h3>
      <ul>
          <html:messages id="msg">
             <li><bean:write name="msg" /></li>
          </html:messages>
      </ul>
</logic:messagesPresent>
...the rest of the body
</snip>

When I test this setup, when the uri contains 'Al' I get the red
"Messages:" as I suspect, but no list of messages under it.  When I
traverse a resource without the 'Al' in the uri, I do NOT get the red
"Messages:".

I have verified that xerces and the ApplicationResources are loaded from
the Catalina log:

2005-04-06 09:00:02 WebappLoader[/AJDocMan]: Deploy JAR
/WEB-INF/lib/struts.jar to
C:\Java\ArchivedWorkspaces\AJDocMan\WebContent\WEB-INF\lib\struts.jar
2005-04-06 09:00:02 WebappLoader[/AJDocMan]: Deploy JAR
/WEB-INF/lib/xercesImpl.jar to
C:\Java\ArchivedWorkspaces\AJDocMan\WebContent\WEB-INF\lib\xercesImpl.ja
r
2005-04-06 09:00:03 WebappLoader[/AJDocMan]: Deploy JAR
/WEB-INF/lib/xmlParserAPIs.jar to
C:\Java\ArchivedWorkspaces\AJDocMan\WebContent\WEB-INF\lib\xmlParserAPIs
.jar
2005-04-06 09:00:03 ContextConfig[/AJDocMan]:    Adding path
'/WEB-INF/lib/xercesImpl.jar'
2005-04-06 09:00:03 ContextConfig[/AJDocMan]:    Adding path
'/WEB-INF/lib/xmlParserAPIs.jar'
2005-04-06 09:00:07,500 DEBUG [main] action.ActionServlet
(ActionServlet.java:1209)     - Initializing module path '' message
resources from 'ApplicationResources'
2005-04-06 09:00:07,500 INFO  [main] util.PropertyMessageResources
(PropertyMessageResources.java:127)     - Initializing,
config='ApplicationResources', returnNull=true

These are the xerces-2_6_2 jars from the dist.

What can I check next?


Michael Oliver
CTO
Alarius Systems LLC
3325 N. Nellis Blvd, #1
Las Vegas, NV 89115
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com
-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk] 
Sent: Tuesday, April 05, 2005 5:09 PM
To: Struts Users Mailing List
Subject: Re: Html:messages vs html:errors

One cause of this is if it can't find the message key in your
application
resources and you have your message resources configured with
null="true".
If you change your message resources config to null="false" in your
struts-config.xml....

 <message-resources null="false"
parameter="myPackage.ApplicationResources"/>

Then if it can't find the message for some reason, you should get the
following displayed.....

        <h3><font color="red"></font>Messages:</h3>
            <ul>

                <li> ???en_US.error.detail????</li>
            </ul>

Another cause...do you have the taglib declaration for the html tags at
the
top of your page?

Anyway, what you have looks good, just a matter of debugging which bits
of
struts are not configured properly.

Nialll

----- Original Message ----- 
From: "Michael Oliver" <ol...@sourceonenet.com>
Sent: Wednesday, April 06, 2005 12:25 AM


> I tried the example from the HelpTagsErrorsAndMessages.html in my jsp
> near the top of the body.
>
> <logic:messagesPresent>
>
>        <h3><font color="red"></font>Messages:</h3>
>            <ul>
>                <html:messages id="msg">
>                    <li><bean:write name="msg" /></li>
>                </html:messages>
>            </ul>
>
> </logic:messagesPresent>
>
> The action that forwards to that jsp has:
>
> ActionErrors errors = new ActionErrors();
> errors.add(ActionErrors.GLOBAL_MESSAGE, new
> ActionMessage("error.detail",retStatus));
> this.saveErrors(request, errors);
>
> where retStatus is a string.
>
> And in my ApplicationResources.properties I have
>
> error.detail={0}
>
> But when I run it I get
>
> org.apache.jasper.JasperException: Cannot find bean msg in any scope
> ...
> ----- Root Cause -----
> javax.servlet.ServletException: Cannot find bean msg in any scope



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



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



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