Forums Register Login

command button with oncomplete ?

+Pie Number of slices to send: Send
Hi Folks

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.
+Pie Number of slices to send: Send
I'm not quite sure what that means, but there shouldn't be a problem. I do stuff like that all the time.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Whoops. Got my wires crossed there.

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.
+Pie Number of slices to send: Send
 

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)
+Pie Number of slices to send: Send
Mining this because I found it on google.

With :



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.
It's just a flesh wound! Or a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 34242 times.
Similar Threads
How to set the focus or navigate to the top of the JSP after submit ?
Get the return value of ajax action
How to write boolean expression from string in JSF?
Rich Face issue
Misusing InPlaceEditor
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:29:50.