You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nikola Milikic <ni...@gmail.com> on 2011/03/04 12:38:44 UTC
Invoke method after page is loaded; when method finishes, redirect to
another page
Hi to all,
I'm a newbie to Tapestry and would be grateful for a small assistance.
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?
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.
I would be grateful for help here, or if there is a more subtle solution for
my idea, I'm open to suggestions.
Thanks!
Best,
Nikola
Email: nikola.milikic@gmail.com
URL: nikola.milikic.info
Re: Invoke method after page is loaded; when method finishes,
redirect to another page
Posted by Nikola Milikic <ni...@gmail.com>.
Thanks all for the tips!
I must admit I looked into all your suggestions and links, but wasn't able
to get my head around them.
But I managed to come up with the workaround. Since I'm using JQuery
Tapestry module, I was able to display ajax loader icon and appropriate text
on the form submit. This code will actually be invoked before the form
submit.
<script>
> $("#keywordsForm").submit(function () {
> $("#loadingText").html('<img src="${context:images/ajax-loader.gif}" />
> Please wait.');
> });
> </script>
Thanks anyway, I appreciate it!
Best,
Nikola
Email: nikola.milikic@gmail.com
URL: nikola.milikic.info
On Fri, Mar 4, 2011 at 4:41 PM, Kalle Korhonen
<ka...@gmail.com>wrote:
> You don't need multiple pages for it, you can just do it all in one
> page if you don't mind some ajax (no scripting needed).
> ProgressiveDisplay is ideal for this
> (
> http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/ProgressiveDisplay.html
> ).
>
> Kalle
>
>
> On Fri, Mar 4, 2011 at 4:37 AM, LLTYK <LL...@mailinator.com> wrote:
> > Use a meta refresh (it'll probably have to be in the tag somehow). Or
> > javascript, to hit the same url.
> >
> > @Inject
> > private ComponentResources componentResources;
> >
> > @OnEvent("calculate")
> > ResultPage calculate() { .... }
> >
> > public String getCalculateUrl()
> > {
> > return componentResources.createEventLink("calculate).toString();
> > }
> >
> >
> >
> >
> > --
> > View this message in context:
> http://tapestry-users.832.n2.nabble.com/Invoke-method-after-page-is-loaded-when-method-finishes-redirect-to-another-page-tp6088155p6088324.html
> > Sent from the Tapestry Users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > 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: Invoke method after page is loaded; when method finishes,
redirect to another page
Posted by Kalle Korhonen <ka...@gmail.com>.
You don't need multiple pages for it, you can just do it all in one
page if you don't mind some ajax (no scripting needed).
ProgressiveDisplay is ideal for this
(http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/ProgressiveDisplay.html).
Kalle
On Fri, Mar 4, 2011 at 4:37 AM, LLTYK <LL...@mailinator.com> wrote:
> Use a meta refresh (it'll probably have to be in the tag somehow). Or
> javascript, to hit the same url.
>
> @Inject
> private ComponentResources componentResources;
>
> @OnEvent("calculate")
> ResultPage calculate() { .... }
>
> public String getCalculateUrl()
> {
> return componentResources.createEventLink("calculate).toString();
> }
>
>
>
>
> --
> View this message in context: http://tapestry-users.832.n2.nabble.com/Invoke-method-after-page-is-loaded-when-method-finishes-redirect-to-another-page-tp6088155p6088324.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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: Invoke method after page is loaded; when method finishes,
redirect to another page
Posted by LLTYK <LL...@mailinator.com>.
Use a meta refresh (it'll probably have to be in the tag somehow). Or
javascript, to hit the same url.
@Inject
private ComponentResources componentResources;
@OnEvent("calculate")
ResultPage calculate() { .... }
public String getCalculateUrl()
{
return componentResources.createEventLink("calculate).toString();
}
--
View this message in context: http://tapestry-users.832.n2.nabble.com/Invoke-method-after-page-is-loaded-when-method-finishes-redirect-to-another-page-tp6088155p6088324.html
Sent from the Tapestry Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Invoke method after page is loaded; when method finishes,
redirect to another page
Posted by Gillespie59 <em...@atosorigin.com>.
If I understand your question
yourFirstPage.java
@Inject
private myCalculatePage mySecondPage;
void onClickFromMyButton(){
//Call a method to set all the parameters needed for the next page
mySecondPage.setParam(...);
return mySecondPage;
}
yourCalculatePage.java
@Inject
private myResultPage myThirdPage;
void onActivate(){
//Calculation system ...
myThirdPage.setResult("The Result String");
result myThirdPage;
}
myResultPage .java
@Property
@Persist
private String result;
And you can display the result in your tml file with ${result}.
Emmanuel
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Invoke-method-after-page-is-loaded-when-method-finishes-redirect-to-another-page-tp3409329p3409377.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Invoke method after page is loaded; when method finishes,
redirect to another page
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 04 Mar 2011 08:38:44 -0300, Nikola Milikic
<ni...@gmail.com> wrote:
> Hi to all,
Hi!
> 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.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org