File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to call message resource bundle(language properties file) through javascript on JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to call message resource bundle(language properties file) through javascript on JSP?" Watch "How to call message resource bundle(language properties file) through javascript on JSP?" New topic
Author

How to call message resource bundle(language properties file) through javascript on JSP?

Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 141

Hi, I have a language properties file(message resource file). I'm trying to call keys defined in that file in javascript function by using javascript alert() on JSP but it is not coming up.

Code:-


It is just alerting like ???iqNumberFormatCheck???. Exact message is not coming up.

Vinod Vijay Nair
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

You can't do that. The "fmt:message" tag is evaluated on the server as part of the JSP processing which produces the HTML. The Javascript is executed much later, on a different computer, in a different environment (the browser) which doesn't have any access to the resource bundle.

However perhaps evaluating that expression on the server is actually what you want. Is the string "iqNumberFormatCheck" actually a key to the resource bundle? If so then perhaps the problem is just that you didn't use the fmt:message tag correctly, e.g. by not specifying the resource bundle correctly.
Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 141

Paul Clapham wrote:You can't do that. The "fmt:message" tag is evaluated on the server as part of the JSP processing which produces the HTML. The Javascript is executed much later, on a different computer, in a different environment (the browser) which doesn't have any access to the resource bundle.

However perhaps evaluating that expression on the server is actually what you want. Is the string "iqNumberFormatCheck" actually a key to the resource bundle? If so then perhaps the problem is just that you didn't use the fmt:message tag correctly, e.g. by not specifying the resource bundle correctly.


Thanks! I have resolved the issue by myself. I was missing to specify the message bundle first. I used fmt:setBundle and specifed my message resource file. Now it is working fine.
@Paul - 'iqNumberFormatCheck' is the actual key in property file.

:) :) :)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call message resource bundle(language properties file) through javascript on JSP?