aspose file tools*
The moose likes JSF and the fly likes execute javascript after action? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "execute javascript after action?" Watch "execute javascript after action?" New topic
Author

execute javascript after action?

Ronald Johnson
Greenhorn

Joined: Jan 15, 2007
Posts: 18
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

Joined: Jan 25, 2008
Posts: 13
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

Joined: Jan 15, 2007
Posts: 18
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

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


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: execute javascript after action?