File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts/JavaScript changing bean:message value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts/JavaScript changing bean:message value" Watch "Struts/JavaScript changing bean:message value" New topic
Author

Struts/JavaScript changing bean:message value

Ergin Er
Ranch Hand

Joined: Sep 06, 2005
Posts: 60
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

Joined: Oct 29, 2003
Posts: 254
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


http://www.goodercode.com
SCJP 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts/JavaScript changing bean:message value
 
Similar Threads
bean:message tag in option tag. is there a solution?
html:select and internationalization
select drop down question
html:select indexed - idexes the formbean i.s.o. the property
using ajax and struts iterate tags