You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Baptiste Autin - Linkeo RD <ba...@linkeo.com> on 2010/01/15 15:46:55 UTC
Updating a zone before the Ajax request
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Updating a zone before the Ajax request
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 15 Jan 2010 15:58:02 -0200, Baptiste Autin - Linkeo RD
<ba...@linkeo.com> wrote:
> Not as much as something like, say:
> <t:zone before="myfunction" />
> :-)
You're right. You can file a JIRA to request this improvement. :)
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Updating a zone before the Ajax request
Posted by Baptiste Autin - Linkeo RD <ba...@linkeo.com>.
> I think Ajax.Responders.register({ onCreate: function() { ... } )}; is
> easy enough. :)
Not as much as something like, say:
<t:zone before="myfunction" />
:-)
(a special attribute on a t:zone, or on a t:beaneditform, I don't know
what would be the best...)
Your solution also means adding a renderSupport in the Java file...
Moreover, it seems that the JS handler is fired for every Ajax request
triggered from any component in the page... which is not always desirable.
I think I can survive with it anyway :)
Baptiste
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Updating a zone before the Ajax request
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 15 Jan 2010 14:50:07 -0200, Baptiste Autin - Linkeo RD
<ba...@linkeo.com> wrote:
> 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!)
I think Ajax.Responders.register({ onCreate: function() { ... } )}; is
easy enough. :)
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Updating a zone before the Ajax request
Posted by Baptiste Autin - Linkeo RD <ba...@linkeo.com>.
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-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
--
Baptiste Autin
Ingénieur de développement
LINKEO
http://www.linkeo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Updating a zone before the Ajax request
Posted by "Joost Schouten (ml)" <jo...@jsportal.com>.
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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Updating a zone before the Ajax request
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 15 Jan 2010 12:46:55 -0200, Baptiste Autin - Linkeo RD
<ba...@linkeo.com> wrote:
> 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've never tested it, but maybe Prototype's Ajax.Responders object is a
solution: http://www.prototypejs.org/api/ajax/responders
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org