tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiago H. de Paula Figueiredo" <thiag...@gmail.com>
Subject Re: Invoke method after page is loaded; when method finishes, redirect to another page
Date Fri, 04 Mar 2011 12:24:41 GMT
On Fri, 04 Mar 2011 08:38:44 -0300, Nikola Milikic  
<nikola.milikic@gmail.com> wrote:

> Hi to all,


> I'm a newbie to Tapestry and would be grateful for a small assistance.

Welcome to hte mailing list!

> Since in my Tapestry 5.2 application I'm doing some calculations which  
> can take up to 30 seconds, I wanted to implement when a user clicks on a  
> button e.g. 'Calculate' to be transferred to a separate page on which the
> calculation will be done (with some message like "Calculation in  
> progress, please wait" and loading icon).
> My question is how to automatically after the calculation has been done
> (method doing calculation ended) to transfer the user to a separate page  
> to display results?

Remember that HTTP itself doesn't provide server to client communication,  
just the opposite. You'll need some AJAX code to request to the page if  
the calculation is finished. You can find some custom AJAX examples in  
this mailing list or in the Tapestry JumpStart. When it's finished, use  
window.location to redirect.

> My first idea was to annotate the method with @PageLoaded annotation:
> @InjectPage
>> private ResultsPage resultsPage ;
>> @PageLoaded
>> ResultsPage calculate (){
>>         // calculation here
>>         resultsPage.setResults(somethingHere);
>>         return resultsPage;
>> }
> but that wont do it. And in the documentation it is stated that this  
> method should return void.

@PageLoaded is invoked just the first time the page class is instanced,  
and in 5.2 this is going to be done just once for the whole webapp life.

Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.

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

View raw message