Hi This would be a very good solution but when
I test it this way:

 public static void main(String args[])
  {
   ResourceBundle messageresources =
   ResourceBundle.getBundle("ApplicationResources");
 }

I always get an exception:
java.util.MissingResourceException: Can't find bundle for base name 
ApplicationResources

The test class is in the same path as the bundle!

Can you help me?

Nice greetings
Starky



---------- Initial Header -----------

>From      : [EMAIL PROTECTED]
To          : user@struts.apache.org
Cc          :
Date      : Mon, 13 Mar 2006 14:08:09 +0530
Subject : RE: Using message resources in non-action class







> Use resource bundle:
>
> ResourceBundle messageresources  =
> ResourceBundle.getBundle("ApplicationResources");
>
> Or
>
> Properties messageresources = new Properties();
> BufferedInputStream is = new BufferedInputStream(
> getClass().getResourceAsStream("ApplicationResources"));
> properties.load(is);
>
> Chandra
>
>
>
> -----Original Message-----
> From: starki78 [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 13, 2006 1:21 PM
> To: user
> Subject: RE: Using message resources in non-action class
>
> Yes this is a good solution!
> Do you also have a solution
> to access these message resources from a plain java-class there you
> don't have the servlet context?
>
> Nice greetings
>
>
> ---------- Initial Header -----------
>
> From      : [EMAIL PROTECTED]
> To          : user@struts.apache.org, [EMAIL PROTECTED]
> Cc          :
> Date      : Mon, 13 Mar 2006 13:11:34 +0530
> Subject : RE: Using message resources in non-action class
>
>
>
>
>
>
>
> >
> > The following should work.
> >
> > MessageResources messageresources = (MessageResources)
> > servlet.getServletContext().getAttribute("allMessages");
> >
> >
> > Chandra
> >
> > -----Original Message-----
> > From: Anuradha S.Athreya [mailto:[EMAIL PROTECTED]
> > Sent: Monday, March 13, 2006 1:09 PM
> > To: 'Struts Users Mailing List'
> > Subject: Using message resources in non-action class
> >
> > In my struts application, I have resources file
> application.properties.
> > This has been configured in the struts-config.xml file
> >
> >  <message-resources key="allMessages"
> parameter="resources.application"
> > />
> >
> >  Now, I would like to use this in my source code , in a non-action
> > class.
> >
> >  I tried the following
> >
> >  MessageResources messageresources =
> > MessageResources.getMessageResources("allMessages");
> >
> >  When i tried to retrieve the message in the file
> >
> >  String message = messageresources.getMessage("username.invalid");
> >
> >  the message is null,altho' corresponding message for the key
> > "username.invalid" is defined in the application.properties file.
> >
> > Can someone indicate the missing link?
> >
> > Regards,
> > Anuradha S.Athreya
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to