• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Displaying javascript alerts by reading from ApplicationResources

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

For displaying alert messages in javascript function calls I need to read the text from ApplicationResources.properties file.
I have tried the following combinations but nothing seems to be working. The text message is not being read from the properties file. Can someone give me the correct syntax.

1. alert(<bean:message key="message.invalidName"/> ;

2. alert('<bean:message key="message.invalidName"/>');

3. alert(<bean:message key='message.invalidName'/>");

4. alert(<bean:message key=message.invalidName'/> ;
In ApplicationResources
message.invalidName=The given name is invalid

Thanks in Advance
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
try to do it . hope it will solve problem.

alert('<bean:message key="message.invalidName"/>');

i think it will work...
 
Varsha Patil
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works. Thanks!
 
Varsha Patil
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I include the javascript code in the jsp file it works. But if I move the javascript code to a separate js file and include that js file in the jsp then it does not work. I wonder why?
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because jsp-code is not evaluted in js-files :-)
 
Varsha Patil
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That explains it. Thanks
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Jan says is true. However, if you do it like this:

<script type="text/javascript" src="myJavaScript.jsp></script>

It does work. This is assuming that myJavaScript.jsp contains javascript code with some JSP or Struts tags included.
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks merrill, i did not think that far...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic