permaculture playing cards*
The moose likes JSF and the fly likes how to get managed bean properties in included js file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "how to get managed bean properties in included js file." Watch "how to get managed bean properties in included js file." New topic
Author

how to get managed bean properties in included js file.

roby george
Ranch Hand

Joined: Sep 08, 2010
Posts: 31
Hello,
we are using JSF1.1, JSTL, webui, SUN-RI

I have a jsp page which is using JSTL , In which we include external JS files like bellow
<webuijsf:script url="resources/reports.js" />

I want to access managed bean propeties in this external js file.
Suppose i have a managed bean named Reports in this i have a properties like noOfReports. I want to access this in my reports.js file.

Although we are able to access the same properties in js code(under <script> </script> tag) of same jsp page like bellow.
var numberOfCoverage1= '${Reports.noOfReports}'

But we have a requirement to access the managed bean properties in included js file.

Thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Managed beans live on the server. JavaScript runs on the client. For JavaScript to access managed beans you'll have to use AJAX to request sending/receiving data from the managed beans.

It's your call as to what kind of AJAX you want to use: brute force, jQuery, Dojo, or ???.

As a side note, it's also time to consider upgrading from JSF 1.1 to something newer. Especially since JSF2 has built-in AJAX support.

And lose the JSTL.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get managed bean properties in included js file.