You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ashwanth Kumar <as...@gmail.com> on 2009/12/27 01:57:07 UTC

Help with onActivate Page

Hello,

I have a small doubt. I need some clarification regarding the onActivate()
of every Page class..

   1. Is it Overloadable? (I know, it has some internal type casting, still
   wanted to know?)
   2. If No, help me with the following scenario in my project.
   I need to show a page a page to the user, only when it has a context with
   it! Else i need to redirect the user to another page. Though i  link the
   page, only with the t:context, i just need to confirm no one has ever
   bookmarked the page, and is seeing it.


 - Ashwanth Kumar

Re: Help with onActivate Page

Posted by Ashwanth Kumar <as...@gmail.com>.
Thanks Keneth,

That helps a lot!

 - Ashwanth Kumar

On Sun, Dec 27, 2009 at 9:24 AM, Kenneth CH, LEE <kl...@gmail.com> wrote:

> Hi,
>
> You can have multiple event handler for the same event:
>
>  http://tapestry.apache.org/tapestry5/guide/event.html
>
> The one with the same no. of arguments as the no. of context
> parameters will get called, as well as the no-arg one. I figured that
> out with my own experiment.
>
> Hope that helps.
>
> Kenneth
>
>
> 2009/12/27 Ashwanth Kumar <as...@gmail.com>:
> > Hello,
> >
> > I have a small doubt. I need some clarification regarding the
> onActivate()
> > of every Page class..
> >
> >   1. Is it Overloadable? (I know, it has some internal type casting,
> still
> >   wanted to know?)
> >   2. If No, help me with the following scenario in my project.
> >   I need to show a page a page to the user, only when it has a context
> with
> >   it! Else i need to redirect the user to another page. Though i  link
> the
> >   page, only with the t:context, i just need to confirm no one has ever
> >   bookmarked the page, and is seeing it.
> >
> >
> >  - Ashwanth Kumar
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Help with onActivate Page

Posted by "Kenneth CH, LEE" <kl...@gmail.com>.
Hi,

You can have multiple event handler for the same event:

  http://tapestry.apache.org/tapestry5/guide/event.html

The one with the same no. of arguments as the no. of context
parameters will get called, as well as the no-arg one. I figured that
out with my own experiment.

Hope that helps.

Kenneth


2009/12/27 Ashwanth Kumar <as...@gmail.com>:
> Hello,
>
> I have a small doubt. I need some clarification regarding the onActivate()
> of every Page class..
>
>   1. Is it Overloadable? (I know, it has some internal type casting, still
>   wanted to know?)
>   2. If No, help me with the following scenario in my project.
>   I need to show a page a page to the user, only when it has a context with
>   it! Else i need to redirect the user to another page. Though i  link the
>   page, only with the t:context, i just need to confirm no one has ever
>   bookmarked the page, and is seeing it.
>
>
>  - Ashwanth Kumar
>

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


Re: Help with onActivate Page

Posted by Alfonso Quiroga <al...@gmail.com>.
What do you mean with overloadable? something like...

a) void onActivate()
b) void onActivate(String param)

you mean that? I think the easier way is to do only one method:

onActivate(EventContext context), tapestry5 will hit it always.

On Sat, Dec 26, 2009 at 9:57 PM, Ashwanth Kumar
<as...@gmail.com> wrote:
> Hello,
>
> I have a small doubt. I need some clarification regarding the onActivate()
> of every Page class..
>
>   1. Is it Overloadable? (I know, it has some internal type casting, still
>   wanted to know?)
>   2. If No, help me with the following scenario in my project.
>   I need to show a page a page to the user, only when it has a context with
>   it! Else i need to redirect the user to another page. Though i  link the
>   page, only with the t:context, i just need to confirm no one has ever
>   bookmarked the page, and is seeing it.
>
>
>  - Ashwanth Kumar
>

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


Re: Help with onActivate Page

Posted by Ashwanth Kumar <as...@gmail.com>.
Piero,

Thanks a lot!! It worked!

  - Ashwanth

On Sun, Dec 27, 2009 at 6:17 PM, Piero Sartini <li...@pierosartini.de>wrote:

> >   2. If No, help me with the following scenario in my project.
> >   I need to show a page a page to the user, only when it has a context
> with
> >   it! Else i need to redirect the user to another page. Though i  link
> the
> >   page, only with the t:context, i just need to confirm no one has ever
> >   bookmarked the page, and is seeing it.
>
> Instead of using 2 onActivate() methods, you may also make use of
> EventContext. It's often less verbose and better to read:
>
> ----------------------------------
> Object onActivate(EventContext eventContext) {
>  switch (eventContext.getCount()) {
>      case 0:
>            return NoContextPage.class;
>      case 1:
>            this.myparameterstring = eventContext.get(String.class, 1);
>      break;
>  }
> }
> ----------------------------------
>
>
>           Piero
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Help with onActivate Page

Posted by Piero Sartini <li...@pierosartini.de>.
>   2. If No, help me with the following scenario in my project.
>   I need to show a page a page to the user, only when it has a context with
>   it! Else i need to redirect the user to another page. Though i  link the
>   page, only with the t:context, i just need to confirm no one has ever
>   bookmarked the page, and is seeing it.

Instead of using 2 onActivate() methods, you may also make use of
EventContext. It's often less verbose and better to read:

----------------------------------
Object onActivate(EventContext eventContext) {
  switch (eventContext.getCount()) {
      case 0:
            return NoContextPage.class;
      case 1:
            this.myparameterstring = eventContext.get(String.class, 1);
      break;
  }
}
----------------------------------


           Piero

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