You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by e-denton Java Programmer <ja...@e-denton.com> on 2004/01/07 15:41:40 UTC

Resources from ActionForm

Hi,

I want to access a resource bundle (key=PORTAL_RESOURCES) from an ActionForm
to pull out display names for error messages (ActionError). I can't see how
to access the resource bundle and pull out the strings I want.

Thanks for your help.

Will


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


Re: Resources from ActionForm

Posted by e-denton Java Programmer <ja...@e-denton.com>.
Hi,

When I define the message resources as:

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

I can access them from jsp as:

    <bean:message key="portal.cnw"/>
    <bean:message bundle="PortalResources" key="shortTitle"/>

But, when I execute this from an ActionForm:

   MessageResources mrs = (MessageResources) request.getAttribute
("PortalResources");
   System.err.println ("PortalResources: " + mrs);

I get:

    PortalResources: null

Thanks, Will




----- Original Message ----- 
From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>;
"'e-denton Java Programmer'" <ja...@e-denton.com>
Sent: Wednesday, January 07, 2004 8:49 AM
Subject: RE: Resources from ActionForm


> hi,
>
> in an actionForm.validate():
>
> MessageResources res =
> (MessageResources) request.getAttribute(GLOBALS.MESSAGES_KEY); //thats
> default-key
>
> String foo = res.getMessage("my_Key_In_bundle");
> //get an message
>
> greetings
>
>
> -----Original Message-----
> From: e-denton Java Programmer [mailto:java-programmer@e-denton.com]
> Sent: Wednesday, January 07, 2004 3:42 PM
> To: Struts Users Mailing List
> Subject: Resources from ActionForm
>
>
> Hi,
>
> I want to access a resource bundle (key=PORTAL_RESOURCES) from an
> ActionForm to pull out display names for error messages (ActionError). I
> can't see how to access the resource bundle and pull out the strings I
> want.
>
> Thanks for your help.
>
> Will
>
>
> ---------------------------------------------------------------------
> 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
>
>


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


RE: Resources from ActionForm

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
hi,

in an actionForm.validate():

MessageResources res =
(MessageResources) request.getAttribute(GLOBALS.MESSAGES_KEY); //thats
default-key

String foo = res.getMessage("my_Key_In_bundle");
//get an message

greetings


-----Original Message-----
From: e-denton Java Programmer [mailto:java-programmer@e-denton.com] 
Sent: Wednesday, January 07, 2004 3:42 PM
To: Struts Users Mailing List
Subject: Resources from ActionForm


Hi,

I want to access a resource bundle (key=PORTAL_RESOURCES) from an
ActionForm to pull out display names for error messages (ActionError). I
can't see how to access the resource bundle and pull out the strings I
want.

Thanks for your help.

Will


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