wood burning stoves 2.0*
The moose likes JSF and the fly likes calling bean from inside javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "calling bean from inside javascript function" Watch "calling bean from inside javascript function" New topic
Author

calling bean from inside javascript function

anitha meena
Ranch Hand

Joined: Oct 22, 2007
Posts: 40
Hi all ,

I have tried to call jsf bean from javascript , something like




here lastMessageInDB is a method in which it will retrieve the last record inserted into the table

but am not able to get the correct output alert ( am getting the same message even so if some data has been inserted during the alert) ???





Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You need h:outputText to output bean properties into template text.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

You can't "call a bean".

Backing beans are referenced when a JSF page request is made, and that requires an HTTP POST/response cycle. There's no short-circuit calling path - JSF is designed to present an entire formatted page (although certain add-ons like RichFaces can update parts of pages).

Setting up a JSF POST is not something that's easy (or safe) to do manually, so the better way of communicating with the bean is to write a custom servlet that accesses the bean, and have the JavaScript function make an AJAX request to that servlet.


Customer surveys are for companies who didn't pay proper attention to begin with.
anitha meena
Ranch Hand

Joined: Oct 22, 2007
Posts: 40

Thanks alot for the reply , i am just testing the replies
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling bean from inside javascript function