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" <gunnar.eketr...@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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to