You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <il...@gmail.com> on 2009/09/17 15:42:25 UTC
multiple onActivate methods in page handler
I have a situation here: one application page can be rendered using either
one or two parameters in context. What I was expecting is calling onActivate
with signature that exactly matches the number of context parameters.
Instead, framework calls all onActivate methods. I've already found relevant
place in documentation, but I must say this is very confusing.
If I assign context variables to instance fields, I must check (in each
onActivate method) that this particular field was not assigned already. I
guess that calling only one onActivate (the one with method parameters count
exactly matching context parameters count) would be much more consistent.
So, instead of
public void onActivate ( String book ) {
this.bookCode = book;
if ( this.topicId == null ) this.topicId = "";
}
public void onActivate ( String book, String topicId ) {
this.bookCode = book;
this.topicId = topicId;
}
we would have
public void onActivate ( String book ) {
this.bookCode = book;
}
public void onActivate ( String book, String topicId ) {
this.bookCode = book;
this.topicId = topicId;
}
--
Ilya Obshadko
Re: multiple onActivate methods in page handler
Posted by ningdh <ni...@gmail.com>.
Return true in the onActivate handler that will prevent multiple call.
DH
http://www.gaonline.com.cn
----- Original Message -----
From: "Ilya Obshadko"
To: <us...@tapestry.apache.org>
Sent: Thursday, September 17, 2009 9:42 PM
Subject: multiple onActivate methods in page handler
>I have a situation here: one application page can be rendered using either
> one or two parameters in context. What I was expecting is calling onActivate
> with signature that exactly matches the number of context parameters.
> Instead, framework calls all onActivate methods. I've already found relevant
> place in documentation, but I must say this is very confusing.
>
> If I assign context variables to instance fields, I must check (in each
> onActivate method) that this particular field was not assigned already. I
> guess that calling only one onActivate (the one with method parameters count
> exactly matching context parameters count) would be much more consistent.
>
> So, instead of
>
> public void onActivate ( String book ) {
> this.bookCode = book;
> if ( this.topicId == null ) this.topicId = "";
> }
>
> public void onActivate ( String book, String topicId ) {
> this.bookCode = book;
> this.topicId = topicId;
> }
>
> we would have
>
> public void onActivate ( String book ) {
> this.bookCode = book;
> }
>
> public void onActivate ( String book, String topicId ) {
> this.bookCode = book;
> this.topicId = topicId;
> }
>
> --
> Ilya Obshadko
>
Re: multiple onActivate methods in page handler
Posted by Ilya Obshadko <il...@gmail.com>.
Exactly. Although multiple onActivate behavior is documented, it took me a
few hours to figure out what is really happening, because there is a strong
contradiction between expectations and actual behavior; it just doesn't fit
the general logic.
On Fri, Sep 18, 2009 at 1:27 AM, Szemere Szemere <
szemereszemere@googlemail.com> wrote:
> I have to say this feature nearly killed me when I started using Tapestry.
> I
> just couldn't get the logic of how it's supposed to work. I don't think the
> EventContext method is in the spirit of quick and easy programming, whilst
> the onActivate doesn't seem very robust.
> I solved the above issue by using a dummy for the id if it didn't exist
> e.g.
> bookTitle/0
>
--
Ilya Obshadko
Re: multiple onActivate methods in page handler
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 17 Sep 2009 18:27:15 -0300, Szemere Szemere
<sz...@googlemail.com> escreveu:
> I have to say this feature nearly killed me when I started using
> Tapestry. I just couldn't get the logic of how it's supposed to work. I
> don't think the EventContext method is in the spirit of quick and easy
> programming,
Why not?
> whilst the onActivate doesn't seem very robust.
Why not?
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: multiple onActivate methods in page handler
Posted by Szemere Szemere <sz...@googlemail.com>.
I have to say this feature nearly killed me when I started using Tapestry. I
just couldn't get the logic of how it's supposed to work. I don't think the
EventContext method is in the spirit of quick and easy programming, whilst
the onActivate doesn't seem very robust.
I solved the above issue by using a dummy for the id if it didn't exist e.g.
bookTitle/0
Szemere
Re: multiple onActivate methods in page handler
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 17 Sep 2009 10:42:25 -0300, Ilya Obshadko
<il...@gmail.com> escreveu:
> I guess that calling only one onActivate (the one with method
> parameters count exactly matching context parameters count) would be
> much more consistent.
This already exists in Tapestry: onActivate(EventContext context). It will
be invoked with any number of arguments.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org