Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JSTL and simple javascript

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Folks,

A simple problem which I have been breaking my head on....There is a simple javascript function that I have:

function errorAlert(){
var temp = "dialog.close";
var x1 = "<fmt:message key="dialog.close"/>";
var x2 = "<fmt:message key='"+temp+"'/>";
alert(x1);
alert(x2);
}

While alert(x1) always returns the internationalized message from the ApplicationResources.properties alert(x2) gives the message ???dialog.close??? which seems to indicate that the message cannot be retrieved...Any help is glady appreciated....

Thanks...Vijay
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey VJ,

You are getting value in x1 because when on server side your fmt tag was parsed and in that you have specified dialog.close as key which is present in Application files.

In second case when your fmt tag was parsed there is key with value as temp and not as dilaog.close.

This is just the simple execution case of javascript because value in temp will be filled when you jsp will be rendered on browser and not on server side.

I hope i have clarified your doubt !!!

Cheers !!!
Sumit Malik
 
Sheriff
Posts: 67634
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a basic misunderstanding about how JSPs work. Please read this article for some help.
 
Sumit Malik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bear Bibeault yours you refers to whom
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It refers to "VJ Nairo"'s post.
 
Goodbye moon men. Hello tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic