This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Initializing a JavaScript data structure from Java in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Initializing a JavaScript data structure from Java in JSF" Watch "Initializing a JavaScript data structure from Java in JSF" New topic
Author

Initializing a JavaScript data structure from Java in JSF

Wally Hartshorn
Ranch Hand

Joined: Jan 30, 2003
Posts: 77
How can I initialize a complicated JavaScript data structure from Java?

I have a JavaScript data structure that, if hard-coded, would look something like this:


WorkSchedule.js looks like this:


However, the specific values will be pulled from a database by my Java code, which would then initialize the JavaScript data structure. Unfortunately, I don't know how to do that.

In the past, I would place values in hidden fields and then initialize variables from those hidden fields. However, this involves a far more complicated data structure (hashes, arrays, objects, etc).

How could I do this? (I'm using Java 5 and JavaServer Faces, if that matters.)

Thanks!


Wally Hartshorn
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

If you were using straight JSP, this is easy to do using simple JSTL and EL to just spit out the exact construct as shown. That's what server-side templating is all about.

But JSF is its own deal, so I've moved this to the JSF forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Initializing a JavaScript data structure from Java in JSF
 
Similar Threads
An unexpected error has been detected by HotSpot Virtual Machine: jdk1.5_09-b03
SSL error
Timezone Issues
After upgrading the systems to java 1.5.0_09 virtual machine is crashing occasionally
Unix OS on Windows Vista ?