Accessing org.apache.struts.Globals.LOCALE_KEY  in javascript func

Posted on 2012-08-15
Medium Priority
Last Modified: 2012-08-17
Hi Experts,

I am wondering if there is a way to access org.apache.struts.Globals.LOCALE_KEY from javascript func.

I am working on web app(Struts) with English and Chinese version. There are simple javascript popup error messages and I want to change language depends on locale.

Are there better ways to deal with something like this?

Question by:dkim18
  • 2
LVL 86

Expert Comment

ID: 38299636
Write the locale value into the page from the server side so the script can access it. JavaScript runs on the client.

Author Comment

ID: 38302727
how do I write local value from the sever side???
LVL 86

Accepted Solution

CEHJ earned 2000 total points
ID: 38302983
<script type="text/javascript">
  var locale=<%=org.apache.struts.Globals.LOCALE_KEY%>;
  alert('The locale is ' + locale);

Open in new window

would be a simple scriptlet way

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question