• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 67746
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.
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic