Re: multiple onActivate methods in page handler

2009-09-25 Thread P . Stavrinides
> I don't think the EventContext method is in the spirit of quick and easy 
> programming
Only because this feature is missing documentation, which is unfortunate.

> the onActivate doesn't seem very robust
Tapestry is doing a lot of the work for you (serialization / deserialization & 
coercion of params) , but I would tend to agree that there is room for 
improvement, personally I am using the EventContext a lot more now to achieve 
more robustness. EventContext allows you to go a step further and extract and 
decode parameters yourself and even to pass those parameters, so why is this 
not in the spirit of quick and easy programming?

I must admit it took a while to determine best practices, but just remember you 
also have the option to configure a page via its properties and then return the 
page object (for links that are not external of course).

regards,
Peter

- Original Message -
From: "Ilya Obshadko" 
To: "Tapestry users" 
Sent: Friday, 18 September, 2009 08:56:52 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: multiple onActivate methods in page handler

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

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



Re: Multiple onActivate() methods ...

2009-09-24 Thread Thiago H. de Paula Figueiredo
Em Thu, 24 Sep 2009 07:21:22 -0300, Ilya Obshadko  
 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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Multiple onActivate() methods ...

2009-09-24 Thread Szemere Szemere
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 ...

2009-09-24 Thread Vladimir Solomenchuk
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Multiple onActivate() methods ...

2009-09-24 Thread Peter Stavrinides
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" 
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



Re: Multiple onActivate() methods ...

2009-09-24 Thread Ilya Obshadko
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
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


Multiple onActivate() methods ...

2009-09-24 Thread Gunnar Eketrapp
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 in page handler

2009-09-17 Thread Ilya Obshadko
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 <
szemereszem...@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

2009-09-17 Thread Thiago H. de Paula Figueiredo
Em Thu, 17 Sep 2009 18:27:15 -0300, Szemere Szemere  
 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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: multiple onActivate methods in page handler

2009-09-17 Thread Szemere Szemere
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

2009-09-17 Thread Thiago H. de Paula Figueiredo
Em Thu, 17 Sep 2009 10:42:25 -0300, Ilya Obshadko  
 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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: multiple onActivate methods in page handler

2009-09-17 Thread ningdh
Return true in the onActivate handler that will prevent multiple call.

DH
http://www.gaonline.com.cn

- Original Message - 
From: "Ilya Obshadko"
To: 
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
>

multiple onActivate methods in page handler

2009-09-17 Thread Ilya Obshadko
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