Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Accessing MessageResources in an ActionForm

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i need to access the (default) MessageResources file within an ActionForm for filling a Collection with labels that will be shown in the corresponding jsp. i tried to instantiate the class ConfigHelper, and with that having access to the MessageResources file, but this resulted in an error when compiling the jsp.
what i need is the same mechanism i have with the method getResources() in an Action, but within an ActionForm, with the result that i can use any key of this properties file and get the right value i then use as a label for one option element in a <html:select> tag. i do not need some solutions with ActionError, because the keys used there will only be translated when compiling the jsp.
any idea ? thanks & best regards
valley
 
Valentin Treu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:roll:
ok, i found something: adding the following lines
in actionform code:

i haven't tested this, but it looks good...
any comments or other solutions ?
valley
 
Valentin Treu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

...so it works. but you have to check that the
parameter value in struts-config.xml under

is equal to the code line in your ActionForm:

That's it. After doing this you have full access
to your messages.
Enjoy
valley
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and welcome to the Ranch. Please note that your name violates the JavaRanch naming standard that you agreed to when you registered. Please correct it by going to your "edit my profile" page and changing your display name. Thanks.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a note, if you have set the servlet reference in your ActionForm (done automatically on a post by Struts, but needs to be done manually when creating the ActionForm), you can get the message resource from the servlet's methods.
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic