Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts/JavaScript changing bean:message value

 
Ergin Er
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm having a problem with JavaScript with my jsp page containing Struts tiles.
Here is the case:
On change of a <html:select propert="type"> value the text of 2 labels needs to be changed. The labels are implemented with <bean:message> and are bundled with property file. (<bean:message bundle="msg" key="message.label1")

When I change the type in the select box the key needs to be changed to "message.label2".
How do I implement this correctly?

This is what I have so far:





I have changed the bean:message to the following:

This way I thought I could easyly change the property value within the jsp page. So far I haven't managed to get it working. I would appreciate any help.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your bean:message should be within a span tag with an id, that way you can access the innerHTML property from javascript. As for getting messages from resource bundles into javascript you have to do something like this:

<script>
var message = "<bean:message key="something"/>";
</script>

Hope that helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic