You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by EasyStrutser <ja...@aol.com> on 2009/11/21 03:36:41 UTC

Multiple calls of method OnActivate()???

I'm trying to pass parameters from one page to another page using activation
content, like this,

class Search{
...
@InjectPage
private SearchResult result;

Object onSuccess(){
result.setParas(keyword);
return result;
}
...
}


class SearchResult
{
...
String onPassivate(){return keyword;}

void onActivate(String keyword){
System.out.println("id"+id);
Data data=DataDao.findById(keyword);
...
}
}

The problem:
Under the debug mode, i found that OnActivate() method has been called for
three times for the first time just after i started the Jetty server, after
that onActivate() has been always called two times, and i used firefox
firebug to check the response and found double response source of page
"SearchResult", i'm pretty confused by this OnPassivate() and OnActivate()
methods, somebody can 
explain why the OnActivate() has been called multiple times, i mean i passed
only one parameter, OnActivate() method should be called only once, if this
method will be called multiple times, how can i handle my logic in the page
"SearchResult"?  i.e., database access operation in OnActivate() method will
also be called multiple times which is obvious unnecessary!  Is it a bug or
something? 



-- 
View this message in context: http://old.nabble.com/Multiple-calls-of-method-OnActivate%28%29----tp26453228p26453228.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Multiple calls of method OnActivate()???

Posted by Howard Lewis Ship <hl...@gmail.com>.
It's a matter of the least non-desirable behavior. Tapestry's default
scheme URL scheme results in very short, very human-like URLs, but
adds the difficulty that it isn't reasonable to determine which URLs
are for a page and which are bogus.

We could resolve this in a couple of ways, the most effective of which
would be to use a query parameter for the activation context,
rather than using extra path (path after the portion that identifies
the page to activate).  However, query parameters in URLs are
undesirable because they interact poorly with web spiders, such as
Google.

On Sat, Nov 21, 2009 at 6:33 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Sat, 21 Nov 2009 12:23:19 -0200, EasyStrutser <ja...@aol.com> escreveu:
>
>> You are totally right, i added some css directly in the .tml file using
>> "css/app.css" instead of ${context:css/app.css}, that's the problem. after
>> correction, the application work perfectly, thx for your tips, it seems that
>> you have met the problem before?! :D
>
> I and many people here in this list met this problem too. :)
>
>> I think T5 should be more robust to resolve such path problems.
>
> I can't figure how. If your page is /somepage and you use a css/app.css
> relative URL, it becomes /somepage/css/app.css. Tapestry looks at it and
> thinks it is a request for the /somepage page with an activation context
> value of css/app.css. Anyway, the use of relative URLs for assets can be
> problematic at times.
>
> --
> 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
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Multiple calls of method OnActivate()???

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 21 Nov 2009 12:23:19 -0200, EasyStrutser <ja...@aol.com> escreveu:

> You are totally right, i added some css directly in the .tml file using
> "css/app.css" instead of ${context:css/app.css}, that's the problem.  
> after correction, the application work perfectly, thx for your tips, it  
> seems that you have met the problem before?! :D

I and many people here in this list met this problem too. :)

> I think T5 should be more robust to resolve such path problems.

I can't figure how. If your page is /somepage and you use a css/app.css  
relative URL, it becomes /somepage/css/app.css. Tapestry looks at it and  
thinks it is a request for the /somepage page with an activation context  
value of css/app.css. Anyway, the use of relative URLs for assets can be  
problematic at times.

-- 
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: Multiple calls of method OnActivate()???

Posted by EasyStrutser <ja...@aol.com>.
You are totally right, i added some css directly in the .tml file using
"css/app.css" instead of ${context:css/app.css}, that's the problem. after
correction, the application work perfectly, thx for your tips, it seems that
you have met the problem before?! :D. I think T5 should be more robust to
resolve such path problems. 



Thiago H. de Paula Figueiredo wrote:
> 
> Em Sat, 21 Nov 2009 00:36:41 -0200, EasyStrutser <ja...@aol.com>
> escreveu:
> 
>> Is it a bug or something?
> 
> I guess you have some resource (CSS, JavaScript, image) that is included  
> using a relative URL. ;)
> 
> Use ${context:/path/image.jpg} instead of path/image.jpg. It must solve  
> your problem.
> 
> -- 
> 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
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Multiple-calls-of-method-OnActivate%28%29----tp26453228p26457015.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: Multiple calls of method OnActivate()???

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 21 Nov 2009 00:36:41 -0200, EasyStrutser <ja...@aol.com> escreveu:

> Is it a bug or something?

I guess you have some resource (CSS, JavaScript, image) that is included  
using a relative URL. ;)

Use ${context:/path/image.jpg} instead of path/image.jpg. It must solve  
your problem.

-- 
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: Multiple calls of method OnActivate()???

Posted by cordenier christophe <ch...@gmail.com>.
2009/11/21 Thiago H. de Paula Figueiredo <th...@gmail.com>

> Em Sat, 21 Nov 2009 09:32:32 -0200, cordenier christophe <
> christophe.cordenier@gmail.com> escreveu:
>
>  Hi
>>
>
> Hi!
>
>  OnActivate is called once to activate the page.
>>
>
> Right, but when a form is submitted or an ActionLink or EventLink is used,
> onActivate() is invoked twice: one for the action request, one for the
> render request. This happens because Tapestry implements
> redirect-after-post.


Exactly, i should have said OnActivate is called once per request :)


>
>
>  OnPassivate is called each time a link is created to allow you to persist
>> datas between request.
>>
>
> Absolutely right. :)
>
>
> --
> 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: Multiple calls of method OnActivate()???

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 21 Nov 2009 09:32:32 -0200, cordenier christophe  
<ch...@gmail.com> escreveu:

> Hi

Hi!

> OnActivate is called once to activate the page.

Right, but when a form is submitted or an ActionLink or EventLink is used,  
onActivate() is invoked twice: one for the action request, one for the  
render request. This happens because Tapestry implements  
redirect-after-post.

> OnPassivate is called each time a link is created to allow you to  
> persist datas between request.

Absolutely right. :)

-- 
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: Multiple calls of method OnActivate()???

Posted by cordenier christophe <ch...@gmail.com>.
Hi

OnActivate is called once to activate the page. OnPassivate is called each
time a link is created to allow you to persist datas between request.

I had the same problem, but it was firebug that send the second request.

Regards
Christophe.

2009/11/21 EasyStrutser <ja...@aol.com>

>
> I'm trying to pass parameters from one page to another page using
> activation
> content, like this,
>
> class Search{
> ...
> @InjectPage
> private SearchResult result;
>
> Object onSuccess(){
> result.setParas(keyword);
> return result;
> }
> ...
> }
>
>
> class SearchResult
> {
> ...
> String onPassivate(){return keyword;}
>
> void onActivate(String keyword){
> System.out.println("id"+id);
> Data data=DataDao.findById(keyword);
> ...
> }
> }
>
> The problem:
> Under the debug mode, i found that OnActivate() method has been called for
> three times for the first time just after i started the Jetty server, after
> that onActivate() has been always called two times, and i used firefox
> firebug to check the response and found double response source of page
> "SearchResult", i'm pretty confused by this OnPassivate() and OnActivate()
> methods, somebody can
> explain why the OnActivate() has been called multiple times, i mean i
> passed
> only one parameter, OnActivate() method should be called only once, if this
> method will be called multiple times, how can i handle my logic in the page
> "SearchResult"?  i.e., database access operation in OnActivate() method
> will
> also be called multiple times which is obvious unnecessary!  Is it a bug or
> something?
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Multiple-calls-of-method-OnActivate%28%29----tp26453228p26453228.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>