This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Somebody know anything about use a commandButton and execute javascript after httpResponse back to browser ?
I've been used a4j:commandButton with oncomplete propertie....but in this case it only works with ajax request....I need use one withoud ajax...with full HttpRequest/Response.
Regards.
Hi Tim
This is exactly what I need to do ! But the JSF specification dont have this propertie in core <h:commandButton>.
Which kit component have you been used to do this ?
Regards.
The reason why the h:commandButton doesn't support oncomplete is that that's not a standard javascript button action. Oncomplete can ONLY work with AJAX, because a non-AJAX submit results in a whole new view being displayed. It might LOOK like the exact same view as before, but it won't be - and one of the giveaways is that the view window will be erased and redrawn with the new view. And along with wiping out the old view, you also are wiping out the JavaScript context that the old view view had - both code resources and execution states. The JavaScript might still be in cache, but cache doesn't count.
And when a new view gets downloaded to the client, EVERYTHING from the old view is gone. I'm pretty sure I saw a discussion about this in some non-JSF venue, in fact. Possibly even in Danny Goodman's seminal JavaScript book.
The closest you can get is to include an onload script on the view being downloaded.
Kavita Tipnis
Ranch Hand
Joined: Sep 21, 2008
Posts: 177
posted
0
Tim Holloway wrote:
The reason why the h:commandButton doesn't support oncomplete is that that's not a standard javascript button action.
It is plain html input type submit, hence it will always refresh your view/page. It is a brand new request each time.
Tim Holloway wrote:
The closest you can get is to include an onload script on the view being downloaded.
Yes and alternately you can forward/redirect to a different jsp to handle it and have a filter to intercept the new request
(if you are interested in request and response objects)