• Post Reply Bookmark Topic Watch Topic
  • New Topic

command button with oncomplete ?

 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure what that means, but there shouldn't be a problem. I do stuff like that all the time.

 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Cedric Bosch
Ranch Hand
Posts: 99
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!