• Post Reply 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Initializing a JavaScript data structure from Java in JSF

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Paper beats rock. Scissors beats tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic