This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSF and the fly likes how to access resource bundle in included JS file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how to access resource bundle in included JS file" Watch "how to access resource bundle in included JS file" New topic

how to access resource bundle in included JS file

roby george
Ranch Hand

Joined: Sep 08, 2010
Posts: 31

we are using JSF1.1, JSTL, SUN-Ri, webui.

In our JSP page we include the resource bundle like bellow

<f:loadBundle basename="com.bundle.messages" var="bundle"/>

We are able to access resource bundle key/value in jsp or js code (under <script></script> tag) like bellow

But now we have a requirement in which we have to access bundle key/value in INCLUDED js file.
we are including js file like bellow
<webuijsf:script url="resources/reports.js" />

Actually we are trying to implement I18N in our application. And we are trying to fetch the Error messages also from resource bundle. Some of the javascript code is written in jsp page under script tag we dont have any issue to fetch the key/value from resource bundle.
But we have some external js file which we include in our jsp page, in that also there are some Error messages, we also want to access that from resource bundle.
So how can we access bundle from external JS file?

Thanks in advance
Rafael Fontoura

Joined: Nov 06, 2007
Posts: 11
Roby, the same answer gived by Tim on this post is valid to this one. In resume, JS files runs on client side.

SCJP 5.0 | SCWCD 5
I agree. Here's the link:
subject: how to access resource bundle in included JS file
Similar Threads
accessKey and optionsCollection
JSF message in faces-config.xml itself
Can't locate .js (or .css) files from a .jsp page.
call javascript function from external JS file
how to get managed bean properties in included js file.