aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes passing a java value to javascript in a dinamyc way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "passing a java value to javascript in a dinamyc way" Watch "passing a java value to javascript in a dinamyc way" New topic
Author

passing a java value to javascript in a dinamyc way

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 386
Hi,

I am interested in know what way passing a java variable to a javascript piece of code, for example if I have this code:

<script type="text/javascript">

gaq.push(["_setCustomVar", 1, "Name", "${page.pageBean.value", 1]);

</script>

Is there someone here who knows what way do it? Any tip?

Many Thanks


Cheers!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

That's more or less right, although you're going to have to get the syntax of the EL expression correct to make it work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Looks like you are already pretty much doing it (once you fix your syntax), so what's the question?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

By the way, that is not "passing" the data from Java to JavaScript. It's just writing the expression value into the HTML page before it's sent to the browser.

See this JspFaq entry for more details.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: passing a java value to javascript in a dinamyc way