You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Barry Volpe <st...@childrencare.com> on 2003/10/17 18:51:57 UTC

How to retrieve messages from default bundle?

Hi,

Want to expose a message in my action:

In my action I have:
throw new Exception("I have an error"); 

want to use message resource:

message.error="I have an error"  (in applcation.properties)


throw new Exception(message.error);   (I know this doesn't work directly)


Not sure how to set this up.

Appreciate a code example suggestion.

Thanks,
Barry

Re: How to retrieve messages from default bundle?

Posted by Barry Volpe <st...@childrencare.com>.
Works thanks!

----- Original Message ----- 
From: "Kris Schneider" <kr...@dotech.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, October 17, 2003 10:19 AM
Subject: Re: How to retrieve messages from default bundle?


> Something like this should work:
>
> MessageResources resources = getResources(request);
> String msg = resources.getMessage("message.error");
> throw new Exception(msg);
>
> Quoting Barry Volpe <st...@childrencare.com>:
>
> > Hi,
> >
> > Want to expose a message in my action:
> >
> > In my action I have:
> > throw new Exception("I have an error");
> >
> > want to use message resource:
> >
> > message.error="I have an error"  (in applcation.properties)
> >
> >
> > throw new Exception(message.error);   (I know this doesn't work
directly)
> >
> >
> > Not sure how to set this up.
> >
> > Appreciate a code example suggestion.
> >
> > Thanks,
> > Barry
>
>
> -- 
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>



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


Re: How to retrieve messages from default bundle?

Posted by Kris Schneider <kr...@dotech.com>.
Something like this should work:

MessageResources resources = getResources(request);
String msg = resources.getMessage("message.error");
throw new Exception(msg);

Quoting Barry Volpe <st...@childrencare.com>:

> Hi,
> 
> Want to expose a message in my action:
> 
> In my action I have:
> throw new Exception("I have an error"); 
> 
> want to use message resource:
> 
> message.error="I have an error"  (in applcation.properties)
> 
> 
> throw new Exception(message.error);   (I know this doesn't work directly)
> 
> 
> Not sure how to set this up.
> 
> Appreciate a code example suggestion.
> 
> Thanks,
> Barry


-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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