Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

initializing javascript variable

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello,
I am experiencing the following problem in my JSP page which uses javascript;
I need to intialize a javascript variable as follows:
rootFld = F("class").I("1.1").I("1.2")._(F("1.3").I("1.3.1").I("1.3.2"))._(F("1.4").I("1.4.1"))._(F("1.5").I("1.5.2")) ;
This variable represents a dynamic tree structure that is to be displayed on the webpage.
I need to initialize the above variable from a variable in java scriptlet. As you can see the variable is not a string and I am not sure how to initiaze it using a java variable.
Any help is much appreciated
thanks
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
My guess is that you are getting a little tangled between what happens when the JSP is running (the page is generated as a load of text) and when the page is being shown by the browser (HTML is formatted and displayed, JavaScript is run).
If you want to generate the text you have shown at "JSP" time, just build it in a StringBuffer exactly as you have shown it here, then write that StringBuffer to the output stream. Your custom-built JavaScript instructions will then be included in the page, ready to be run when the page is displayed.
Has that helped ?
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please don't post the same messag ein more than one forum. You obviously read more than one forum, and so do the people who might answer your question.
There are more answers to this question in this other thread so I have closed this one.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic