aspose file tools*
The moose likes JSF and the fly likes Internationalized messages in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Internationalized messages in javascript" Watch "Internationalized messages in javascript" New topic
Author

Internationalized messages in javascript

Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Hi - I need to get the message from property file and show it in javascript alert. I'm using

<f:loadBundle basename="resources.myProp" var="Msg"/>
var can =${Msg.myMessage};
var con=confirm(can);

I'm getting javascript error even though i can see that the appropriate text is loaded when i viewed the source. Anyother solution other than getting it in my backing bean itself?
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

If i use

<f:loadBundle basename="resources.myProp" var="Msg"/>

<t:inputHidden value="#{Msg.myMessage}" id="msgtext" forceId="true"/>

var can =document.getElementById('msgtext');
var con=confirm(can);



Alert message is proper, no javascript error but the page is not getting submitted. If i click on button, same page is refreshed.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The JavaScript error has nothing to do with JSF. Your JavaScript syntax is simply invalid.
In the second case, your JavaScript logic is most probably plain wrong.

There's a nice JavaScript tutorial at w3schools.com and there's also a HTML/JavaScript forum here at JavaRanch. You hay have more luck when learning the language properly and posting JS problems at the JS forum.

Just keep in min that JSF just generates HTML/CSS/JS/whateverClientSide output. Open the page in your webbrowser and do a view source. Make sure that the Javascript in there looks fine and has no syntax errors.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internationalized messages in javascript