• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initializing a JavaScript data structure from Java in JSF

 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic