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.
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)
The function specified in the onevent attribute will be executed at 3 points in time : begin, complete and success. Begin is before the ajax request, complete is after and success is when the dom has been updated.
I found that in a post from BalusC but I can't get my hands on it.
Post by:autobot
It's just a flesh wound! Or a tiny ad:
a bit of art, as a gift, that will fit in a stocking