Thanks a lot guys. It works!

(... even if I think the solution is rather complicated for a simple need... It would be great if a future release of Tapestry offered a way to call some Javascript just before an Ajax request!)


Joost Schouten (ml) a écrit :
An easier solution would be to like Thiago sugested. Here's my code that does the trick.

Cheers,
Joost

.js file:
AjaxProgressTracker = {
   init: function() {
       Ajax.Responders.register({
           onCreate: function() {
               // ajax request is sent
               AjaxProgressTracker.ajaxCalled();
           },
           onComplete: function() {
               // ajax response is back.
               AjaxProgressTracker.ajaxEnded();
           }
       });
   },
   ajaxCalled : function () {
       $$('body')[0].addClassName('ajaxInProgress');
   },
   ajaxEnded : function () {
       $$('body')[0].removeClassName('ajaxInProgress');
   }
}

LayoutComponent.java

@SetupRender
   private void setup() {
       renderSupport.addScript("AjaxProgressTracker.init();");
   }

tml:
<div id="ajaxLoadingIndicator">
   loading
</div>

css:
#ajaxLoadingIndicator{
   position: absolute;
   z-index: 101;
   width: 5em;
   height: 1.6em;
   position: fixed;
   left: 50%;
   margin-left: -2.5em;
   top: 2em;
   padding: 0.3em 0.3em 0.3em 2.5em;
   display: none;
}

.ajaxInProgress #ajaxLoadingIndicator {
   display: block;
}


Baptiste Autin - Linkeo RD wrote:
Hello,

I have a BeanEditForm that updates a Zone through the "zone" attribute.
It works fine.

Now, I would like to display a kind of loading icon (or invoke a Javascript method) just *before* the Ajax request, but I could find any solution. I could not make ProgressiveDisplay work in such a situation (since the page is already fully loaded when the form is submitted) And the "show"/"update" functions of the Zone component, which could have been a workaround, are triggered only after the HTTP response.

Any idea ?

Baptiste

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

--
Baptiste Autin
Ingénieur de développement
LINKEO
http://www.linkeo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to