• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

execute javascript after action?

 
Ronald Johnson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

how can i make sure that a piece of javascript is executed after i called an action on the server?
any ideas how to achieve this (no matter how; jsf, ajax4jsf, rich faces...)

thanks for any tips
 
Manuel DeAngelo
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ronald!

You could just have a variable in your form bean and set this to true in your action and in the jsp / facelet you have an


regards, Manuel
 
Ronald Johnson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi manuel, hmm, let me clarify, i have code like this:



and I want the myFunction() to be called, but only when the action #{someBean.itemClicked} has finished executing.

i can for example not use onComplete attribute since it is just looking at the client side and not on the server side....
[ February 12, 2008: Message edited by: Ronald Johnson ]
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18108
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This gets back to the issue about JSF being based on HTTP and HTTP being a request/response protocol.

When you fire an Action, a request is made to the server. The request is processed as per the JSF lifecycle specs and a response is sent back to the client. The response is going to be a complete HTTP page.

So the answer is: implement an onLoad() JavaScript method. If it will be used on the same page that the request was made from but only after updating, set a page variable that the onLoad method can use to tell it's a reload.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic