This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Reverse Lookup resource key from resource Message in Struts

 
Khurram Butt
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Guyz

i need a way to find the key from the message passed .........
why i need it
i have a application that uses LookupDispatchAction and have corresponding ActionForm classes that validates
the bean properties ..... it actually do conditional validation based on which button pressed on the page by using mapping.getParameter()

and then extracting its value from request to decide which button is pressed like

if(request.getParameter(mapping.getParameter()).equals("SAVE")) // then do validation associated with save operation

if(request.getParameter(mapping.getParameter()).equals("DEL")) // then do validation associated with del operation

now my application is going to support multi languages here the problem arise the message that will come from button will come in different languages and it will cause to stop the validation
i have considerable amount of ActionForms and i dont want to edit every form

so i was looking to do any reverse lookup of keys from messages so that i can extract english messages and update accordingly

any new ideas to this problem are also welcome

thanks
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always check for the button pressed like this:



This uses the id of the button, not the value. I think this is what you want.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Khurram Butt
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thanks Richard for replying
yes good technique but this way will require me to change code at both ends jsps and ActionForms because in jsps i can't see any property/attribute of id .

thanks
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All tags have an id attribute. In Struts 1 it is styleId. In Struts 2 it is id.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic