• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing a java value to javascript in a dinamyc way

 
Isaac Ferguson
Ranch Hand
Posts: 831
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you are already pretty much doing it (once you fix your syntax), so what's the question?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic