You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gunnar Eketrapp <gu...@gmail.com> on 2009/09/24 12:13:47 UTC

Multiple onActivate() methods ...

Hi!

I have a page that may take a username as paramater.


The main setup metod was named

Object onActivate() {

   -- Fetch and process some data before rendering ---

    return null;
}

then I added a

void onActivate(String username)  {
//  Remember user to be used in other onActivate() method !!!
...
}

Everyhting seemed to be ok until i figured out that the second method is
called after the first method.

Obviously I am have not grasped the event handling mechanism at all ...

A hint anyone? I'll buy you a beer next time you are in town!

Thanks in advance,
Gunnar Eketrapp
Stockholm Sweden

Re: Multiple onActivate() methods ...

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 24 Sep 2009 07:21:22 -0300, Ilya Obshadko  
<il...@gmail.com> escreveu:

> (I was stuck at the same point about week ago and there was a small
> discussion about it. I still insist that current behavior is misleading.)

Hi, Ilya!

I still don't get why you think the current behavior is misleading (at  
least not when you have a single onActivate(EventContext) method).

-- 
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 ...

Posted by Ilya Obshadko <il...@gmail.com>.
Return true from onActivate () to prevent further processing. Or just use
onActivate ( EventContext ctx ).
(I was stuck at the same point about week ago and there was a small
discussion about it. I still insist that current behavior is misleading.)


On Thu, Sep 24, 2009 at 2:13 PM, Gunnar Eketrapp
<gu...@gmail.com>wrote:

> Hi!
>
> I have a page that may take a username as paramater.
>
>
> The main setup metod was named
>
> Object onActivate() {
>
>   -- Fetch and process some data before rendering ---
>
>    return null;
> }
>
> then I added a
>
> void onActivate(String username)  {
> //  Remember user to be used in other onActivate() method !!!
> ...
> }
>
> Everyhting seemed to be ok until i figured out that the second method is
> called after the first method.
>
> Obviously I am have not grasped the event handling mechanism at all ...
>
> A hint anyone? I'll buy you a beer next time you are in town!
>
> Thanks in advance,
> Gunnar Eketrapp
> Stockholm Sweden
>



-- 
Ilya Obshadko

Re: Multiple onActivate() methods ...

Posted by Szemere Szemere <sz...@googlemail.com>.
All this renewed talk about OnActivate, has finally piqued my interest in
digging down into EventContext. i should get to it next week. I never looked
at it before because there wasn't any documentation (18 months ago).

If EventContext is easy to use, then it should really be the only way to
access parameters for any website that wants to stop users from passing the
wrong number of parameters maliciously.

Szemere

Re: Multiple onActivate() methods ...

Posted by Vladimir Solomenchuk <vo...@gmail.com>.
another way is returning true as onActivate result - this will stop  
bubbling

Object onActivate()
{
...
}
Object onActivate(String username)
{
...
return true;
}


On 24.09.2009, at 14:13, Gunnar Eketrapp wrote:

> Hi!
>
> I have a page that may take a username as paramater.
>
>
> The main setup metod was named
>
> Object onActivate() {
>
>   -- Fetch and process some data before rendering ---
>
>    return null;
> }
>
> then I added a
>
> void onActivate(String username)  {
> //  Remember user to be used in other onActivate() method !!!
> ...
> }
>
> Everyhting seemed to be ok until i figured out that the second  
> method is
> called after the first method.
>
> Obviously I am have not grasped the event handling mechanism at  
> all ...
>
> A hint anyone? I'll buy you a beer next time you are in town!
>
> Thanks in advance,
> Gunnar Eketrapp
> Stockholm Sweden


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


Re: Multiple onActivate() methods ...

Posted by Peter Stavrinides <P....@albourne.com>.
Hi Gunner,

Sometimes activation parameters are unavoidable, when using them there is a lot to consider:

- Type Coercion and Coercion errors
- Variable number of arguments
- Null / empty arguments
- Flow control

Better than having multiple onActivate() methods, use:

Object onActivate(EventContext eContext){
 ... 
return null;
}

So you can do all of that in one place or in a base page. The EventContext interface includes the ability to coerce or encode parameters as needed, it also provides an argument count so you can eliminate the overloaded methods. Its typically used:

int myArg = eContext.get(Integer.class, i); where i is the index of the argument.

cheers,
Peter

-- 
If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Please visit http://www.albourne.com/email.html for important additional terms relating to this e-mail.

----- Original Message -----
From: "Gunnar Eketrapp" <gu...@gmail.com>
To: users@tapestry.apache.org
Sent: Thursday, 24 September, 2009 13:13:47 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Multiple onActivate() methods ...

Hi!

I have a page that may take a username as paramater.


The main setup metod was named

Object onActivate() {

   -- Fetch and process some data before rendering ---

    return null;
}

then I added a

void onActivate(String username)  {
//  Remember user to be used in other onActivate() method !!!
...
}

Everyhting seemed to be ok until i figured out that the second method is
called after the first method.

Obviously I am have not grasped the event handling mechanism at all ...

A hint anyone? I'll buy you a beer next time you are in town!

Thanks in advance,
Gunnar Eketrapp
Stockholm Sweden

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