This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Internationalized messages in javascript

 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
Flex Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic