This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Internationalized messages in javascript" Watch "Internationalized messages in javascript" New topic

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 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:
subject: Internationalized messages in javascript
Similar Threads
Embedding Javascript in a facelet Page
Add & Delete Table rows dynamically
Don't mistake this for a troll post. Elegant Javascript
BigDecimal in JavaScript
How can I struts tag library with in javascript ?