Re: Resources from ActionForm
Thanks, everyone. This worked! - Original Message - From: "Shishir K. Singh" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, January 07, 2004 9:47 AM Subject: RE: Resources from ActionForm Ooops..I am sorry. I think you can do MessageResources resource = (MessageResources) servlet.getServletContext().getAttribute("PORTAL_RESOURCES"); servlet is a protected field in ActionForm and hence accesible. Shishir -Original Message- From: Shishir K. Singh Sent: Wednesday, January 07, 2004 10:20 AM To: 'Struts Users Mailing List' Subject: RE: Resources from ActionForm I think the messageresources is stored in the the application context. Don't know if you can access the application context in the form. One way would be to subclass RequestProcessor, put a static function to get the resource and use that. I would have been happier if an extra function could have been provided in ActionMessage or ActionError like getMessage() which would have returned the full message after substitution. -Original Message- From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 9:50 AM To: 'Struts Users Mailing List'; 'e-denton Java Programmer' 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:[EMAIL PROTECTED] 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: [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]
Re: Resources from ActionForm
Hi, When I define the message resources as: I can access them from jsp as: 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" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>; "'e-denton Java Programmer'" <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] > 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: [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]
Re: Resources from ActionForm
Hi Matthias. Yes, but this is only half the truth.. You have the same key in the servlet-context and in the request context. For each modul you have the MESSAGES_KEY with the specific module suffix. At each request struts puts also the resources of the _current module_ in the request-context. If you have only one struts module, both contextes have the same resources. So: If you use the request.getAttribute method you are on the right way, regardless which module you are into Manfred Matthias Wessendorf wrote: hi again in my validate() this gets default-messageResources: MessageResources m = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); System.out.println(m.getMessage("myKey")); and that an alternative Resource: (this servlet(application)-context...) sorry... wrong in mind :-( MessageResources ms = (MessageResources) getServlet().getServletContext().getAttribute("alternativ"); System.out.println(ms.getMessage("myKey")); -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 4:20 PM To: Struts Users Mailing List Subject: RE: Resources from ActionForm I think the messageresources is stored in the the application context. Don't know if you can access the application context in the form. One way would be to subclass RequestProcessor, put a static function to get the resource and use that. I would have been happier if an extra function could have been provided in ActionMessage or ActionError like getMessage() which would have returned the full message after substitution. -Original Message- From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 9:50 AM To: 'Struts Users Mailing List'; 'e-denton Java Programmer' 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:[EMAIL PROTECTED] 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: [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] -- === Dipl.-Inf. Manfred Wolff --- phone neusta : +49 421 20696-27 phone : +49 421 534522 mobil : +49 178 49 18 434 eFax : +49 1212 6 626 63 965 33 --- Diese E-Mail enthält möglicherweise vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Resources from ActionForm
Ooops..I am sorry. I think you can do MessageResources resource = (MessageResources) servlet.getServletContext().getAttribute("PORTAL_RESOURCES"); servlet is a protected field in ActionForm and hence accesible. Shishir -Original Message- From: Shishir K. Singh Sent: Wednesday, January 07, 2004 10:20 AM To: 'Struts Users Mailing List' Subject: RE: Resources from ActionForm I think the messageresources is stored in the the application context. Don't know if you can access the application context in the form. One way would be to subclass RequestProcessor, put a static function to get the resource and use that. I would have been happier if an extra function could have been provided in ActionMessage or ActionError like getMessage() which would have returned the full message after substitution. -Original Message- From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 9:50 AM To: 'Struts Users Mailing List'; 'e-denton Java Programmer' 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:[EMAIL PROTECTED] 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: [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]
RE: Resources from ActionForm
hi again in my validate() this gets default-messageResources: MessageResources m = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); System.out.println(m.getMessage("myKey")); and that an alternative Resource: (this servlet(application)-context...) sorry... wrong in mind :-( MessageResources ms = (MessageResources) getServlet().getServletContext().getAttribute("alternativ"); System.out.println(ms.getMessage("myKey")); -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 4:20 PM To: Struts Users Mailing List Subject: RE: Resources from ActionForm I think the messageresources is stored in the the application context. Don't know if you can access the application context in the form. One way would be to subclass RequestProcessor, put a static function to get the resource and use that. I would have been happier if an extra function could have been provided in ActionMessage or ActionError like getMessage() which would have returned the full message after substitution. -Original Message- From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 9:50 AM To: 'Struts Users Mailing List'; 'e-denton Java Programmer' 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:[EMAIL PROTECTED] 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: [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]
RE: Resources from ActionForm
I think the messageresources is stored in the the application context. Don't know if you can access the application context in the form. One way would be to subclass RequestProcessor, put a static function to get the resource and use that. I would have been happier if an extra function could have been provided in ActionMessage or ActionError like getMessage() which would have returned the full message after substitution. -Original Message- From: Matthias Wessendorf [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 9:50 AM To: 'Struts Users Mailing List'; 'e-denton Java Programmer' 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:[EMAIL PROTECTED] 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: [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]
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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]