You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Fleischle, Samuel" <s....@key-software.com> on 2005/04/04 10:08:39 UTC

Define more than one messages.properties

I have a Struts-app with a really big messages.properties file. I want to
split this file in some smaller and logic parts to get a better overview.

 

I know there is the possibility to create modules with its own
messages.properties. But I have some messages used in every module the same
way, e.g. menu entries, error messages... But if I create modules, I have to
copy these messages in each module and if I update these messages, I have to
update them in each module. I think this is no really good way.

 

Is there any possibility, to define a comma separated list of
messages.properties in one module, the same way I define more
struts-config.xml files, which will  be concatenated at runtime?

 

Regards,

Sam


Re: Html:messages vs html:errors

Posted by Hubert Rabago <hr...@gmail.com>.
Here are wiki topics that discuss this:

http://wiki.apache.org/struts/StrutsDeprecatedActionErrors
http://wiki.apache.org/struts/ActionErrorsAndActionMessages

Hubert

On Apr 5, 2005 8:18 AM, Fergal O'Shea <fe...@activehotels.com> wrote:
> 
> Hi,
> 
> I'm a Struts newbie. A lot of the books and documentation I have on Struts
> is pre 1.2 and uses html:errors and ActionErrors. Given ActionErrors is
> deprecated, I'd like to use ActionMessages for some new JSPs I'm writing.
> 
> Does anyone know of links to more up-to-date articles or documentation
> discussing the transition from Errors to Messages, what's similar and what
> has changed ?
> I've looked at the Apache website, but it mostly still seems to talk in
> terms of ActionErrors.
> 
> TIA,
> 
> Fergal
>

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


RE: Html:messages vs html:errors

Posted by Michael Oliver <ol...@sourceonenet.com>.
Thanks,

But ARG!!!! That wasn't it.  I changed the <message-resources tag as you
suggest, 

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

however I am still not displaying any messages not even the ???null???
there are also no exceptions in the log.

Is there some other package I can add a logger for that might yield a
hint as to what's going on?

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: Wednesday, April 06, 2005 11:30 AM
To: Struts Users Mailing List
Subject: Re: Html:messages vs html:errors

The problem is with how you've configured your messages resources.
Because
you've specified a key your message resources are not being stored under
the
"default" messages resources key. There being stored under the bundle
key
"ApplicationResources". You just need to remove that (and the id, its
unnecessary) and have the following...

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

If you do specify a "key" value in the <message-resources> element,
then
you need to use the same value in the "bundle" attribute of the JSP
tags,
something like the following should work with what you had set up...

   <bean:message key="myMessage.key" bundle="ApplicationResources" />

I'm going to post an update to the page I originally put up which
includes
info on this - I'll post to the list when its ready.

Niall

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


> 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:



---------------------------------------------------------------------
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


Re: Html:messages vs html:errors

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
The problem is with how you've configured your messages resources. Because
you've specified a key your message resources are not being stored under the
"default" messages resources key. There being stored under the bundle key
"ApplicationResources". You just need to remove that (and the id, its
unnecessary) and have the following...

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

If you do specify a "key" value in the <message-resources> element,  then
you need to use the same value in the "bundle" attribute of the JSP tags,
something like the following should work with what you had set up...

   <bean:message key="myMessage.key" bundle="ApplicationResources" />

I'm going to post an update to the page I originally put up which includes
info on this - I'll post to the list when its ready.

Niall

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


> 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:



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


message-resources null="false" returnNull=true

Posted by Michael Oliver <ol...@sourceonenet.com>.
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


RE: Html:messages vs html:errors

Posted by Michael Oliver <ol...@sourceonenet.com>.
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


Re: Html:messages vs html:errors

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
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


RE: Html:messages vs html:errors

Posted by Michael Oliver <ol...@sourceonenet.com>.
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
...

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 12:28 PM
To: Struts Users Mailing List
Subject: Re: Html:messages vs html:errors

>From this and other messages I think you've got the wrong end of the
stick
regarding the <html:errors> tag. You can use either <html:errors> or
<html:messages> with ActionMessage, its just down to personal
preference.
I've added a page comparing <html:errors> and <html:messages> here:

http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

You can use either

As for the validate method in your action form - then whether you use
<html:errors> or <html:messages> the you can do something like the
following...

public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {

   ActionErrors errors = new ActionErrors();

   if (<some conditon here>) {
        errors.add("myProperty", new ActionMessage("myProperty.error"));
   }

   return errors;

}

Niall

----- Original Message ----- 
From: "Fergal O'Shea" <fe...@activehotels.com>
To: "'Riyaz Mansoor'" <rm...@gmail.com>; "'Struts Users Mailing List'"
<us...@struts.apache.org>
Sent: Tuesday, April 05, 2005 5:21 PM
Subject: RE: Html:messages vs html:errors


>
> We don't seem to have struts-examples.war readily available here at
work.
>
> Does anyone have an example of overriding an ActionForm's validate()
method,
> but using ActionMessage instead of ActionError (I presume you still
have
to
> use a Collection of ActionErrors), and using html:messages instead of
simple
> old <html:errors/>.
> Specifically, how does one tie in the id parameter in html:messages
with
the
> ActionErrors Collection returned by one's validate() method ?



---------------------------------------------------------------------
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


Re: Html:messages vs html:errors

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
>From this and other messages I think you've got the wrong end of the stick
regarding the <html:errors> tag. You can use either <html:errors> or
<html:messages> with ActionMessage, its just down to personal preference.
I've added a page comparing <html:errors> and <html:messages> here:

http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

You can use either

As for the validate method in your action form - then whether you use
<html:errors> or <html:messages> the you can do something like the
following...

public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {

   ActionErrors errors = new ActionErrors();

   if (<some conditon here>) {
        errors.add("myProperty", new ActionMessage("myProperty.error"));
   }

   return errors;

}

Niall

----- Original Message ----- 
From: "Fergal O'Shea" <fe...@activehotels.com>
To: "'Riyaz Mansoor'" <rm...@gmail.com>; "'Struts Users Mailing List'"
<us...@struts.apache.org>
Sent: Tuesday, April 05, 2005 5:21 PM
Subject: RE: Html:messages vs html:errors


>
> We don't seem to have struts-examples.war readily available here at work.
>
> Does anyone have an example of overriding an ActionForm's validate()
method,
> but using ActionMessage instead of ActionError (I presume you still have
to
> use a Collection of ActionErrors), and using html:messages instead of
simple
> old <html:errors/>.
> Specifically, how does one tie in the id parameter in html:messages with
the
> ActionErrors Collection returned by one's validate() method ?



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


RE: Html:messages vs html:errors

Posted by Michael Oliver <ol...@sourceonenet.com>.
This seems to be one of the biggest problems for Struts users, I am
still on 1.1 but had so much trouble with <html:errors/> that I am sure
moving to html:messages will be better, I too want to do that, but not
finding what to do.

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: Fergal O'Shea [mailto:fergal@activehotels.com] 
Sent: Tuesday, April 05, 2005 9:22 AM
To: 'Riyaz Mansoor'; 'Struts Users Mailing List'
Subject: RE: Html:messages vs html:errors


We don't seem to have struts-examples.war readily available here at
work.

Does anyone have an example of overriding an ActionForm's validate()
method,
but using ActionMessage instead of ActionError (I presume you still have
to
use a Collection of ActionErrors), and using html:messages instead of
simple
old <html:errors/>.
Specifically, how does one tie in the id parameter in html:messages with
the
ActionErrors Collection returned by one's validate() method ?




> I'm a Struts newbie. A lot of the books and documentation I have on 
> Struts is pre 1.2 and uses html:errors and ActionErrors. Given 
> ActionErrors is deprecated, I'd like to use ActionMessages for some
new
JSPs I'm writing.

the usage is the same. 

actionerrors are dependent on certain keys such as "error.prefix" that
came
with the messageresources file.

messageresources have no such dependencies.

have a look at the struts-examples.war. u'll see all u'll need there :)




---------------------------------------------------------------------
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


RE: Html:messages vs html:errors

Posted by Fergal O'Shea <fe...@activehotels.com>.
We don't seem to have struts-examples.war readily available here at work.

Does anyone have an example of overriding an ActionForm's validate() method,
but using ActionMessage instead of ActionError (I presume you still have to
use a Collection of ActionErrors), and using html:messages instead of simple
old <html:errors/>.
Specifically, how does one tie in the id parameter in html:messages with the
ActionErrors Collection returned by one's validate() method ?




> I'm a Struts newbie. A lot of the books and documentation I have on 
> Struts is pre 1.2 and uses html:errors and ActionErrors. Given 
> ActionErrors is deprecated, I'd like to use ActionMessages for some new
JSPs I'm writing.

the usage is the same. 

actionerrors are dependent on certain keys such as "error.prefix" that came
with the messageresources file.

messageresources have no such dependencies.

have a look at the struts-examples.war. u'll see all u'll need there :)




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


Re: Html:messages vs html:errors

Posted by Riyaz Mansoor <rm...@gmail.com>.
> I'm a Struts newbie. A lot of the books and documentation I have on Struts
> is pre 1.2 and uses html:errors and ActionErrors. Given ActionErrors is
> deprecated, I'd like to use ActionMessages for some new JSPs I'm writing.

the usage is the same. 

actionerrors are dependent on certain keys such as "error.prefix" that
came with the messageresources file.

messageresources have no such dependencies.

have a look at the struts-examples.war. u'll see all u'll need there :)

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


Html:messages vs html:errors

Posted by Fergal O'Shea <fe...@activehotels.com>.
 
Hi,

I'm a Struts newbie. A lot of the books and documentation I have on Struts
is pre 1.2 and uses html:errors and ActionErrors. Given ActionErrors is
deprecated, I'd like to use ActionMessages for some new JSPs I'm writing. 

Does anyone know of links to more up-to-date articles or documentation
discussing the transition from Errors to Messages, what's similar and what
has changed ?
I've looked at the Apache website, but it mostly still seems to talk in
terms of ActionErrors.

TIA,

Fergal


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


RE: Define more than one messages.properties

Posted by Mark Benussi <ma...@hotmail.com>.
Yes.

<message-resources parameter="ApplicationResources" null="false" />
<message-resources key="general" parameter="general.ApplicationResources"
null="false" />
<message-resources key="errors" parameter="errors.ApplicationResources"
null="false" />

Then when you refer to a message from a message resource defined above with
a key just use the 'bundle' attribute of html:errors.

-----Original Message-----
From: Fleischle, Samuel [mailto:s.fleischle@key-software.com] 
Sent: 04 April 2005 09:09
To: user@struts.apache.org
Subject: Define more than one messages.properties

I have a Struts-app with a really big messages.properties file. I want to
split this file in some smaller and logic parts to get a better overview.

 

I know there is the possibility to create modules with its own
messages.properties. But I have some messages used in every module the same
way, e.g. menu entries, error messages... But if I create modules, I have to
copy these messages in each module and if I update these messages, I have to
update them in each module. I think this is no really good way.

 

Is there any possibility, to define a comma separated list of
messages.properties in one module, the same way I define more
struts-config.xml files, which will  be concatenated at runtime?

 

Regards,

Sam


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