Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling bean from inside javascript function

 
anitha meena
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need h:outputText to output bean properties into template text.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18165
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
anitha meena
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks alot for the reply , i am just testing the replies
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic