You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by James Sherwood <js...@rgisolutions.com> on 2009/01/19 19:02:07 UTC

Possible to override onActivate from an extended page?

Hello,

 

I have a login only application and for the most part you just need to be
logged in to use it except for a couple of pages.

 

To enforce this I made a class:

 

Class SecurePage{

 

Object onActivate(){

                If(!visitExists){

                Return index.class;

}

Return null;

 

}

 

I just then extend my pages with this one.(which will have other various
methods common to many pages)

 

My problem:  Is there a way to override the onActivate (or a way around it)
in the page that extends SecurePage so I could perform additional security
checks?

 

Thanks,

--James


Re: Possible to override onActivate from an extended page?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 19 Jan 2009 15:54:32 -0300, James Sherwood  
<js...@rgisolutions.com> escreveu:

> Hello,

Hi!

> Short answer: It is in a different package(base) so the override won't  
> work for a page class in the pages package(or so says my compiler:).

If you declared it package-private (no access modifiers), your compiler is  
right. :)
You can declare public or protected event handlers methods if you want.

> Not so short answer: I really like this thanks!
>
> Long answer:  Looking into it but what is the advantage over just the  
> more simple 'activate'?

You don't have to make your pages extend a base page. All the user access  
logic stays in one place.

-- 
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: Possible to override onActivate from an extended page?

Posted by James Sherwood <js...@rgisolutions.com>.
Hello,

Short answer: It is in a different package(base) so the override won't work
for a page class in the pages package(or so says my compiler:).

Not so short answer: I really like this thanks!

Long answer:  Looking into it but what is the advantage over just the more
simple 'activate'?

--James


-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: January-19-09 3:07 PM
To: Tapestry users
Subject: Re: Possible to override onActivate from an extended page?

Em Mon, 19 Jan 2009 15:02:07 -0300, James Sherwood  
<js...@rgisolutions.com> escreveu:

> My problem:  Is there a way to override the onActivate (or a way around  
> it) in the page that extends SecurePage so I could perform additional  
> security checks?

Short answer: yes, ordinary inheritence works for Tapestry pages too.

Not so short answer: you can have more methods invoked when the page is  
requested:
@OnEvent("activate")
public Object doSomething() { ... }

Long answer: user authentication and other cross-page logic is usually  
better implemented in RequestFilters. Search this mailing list and the  
wiki for examples. :)

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


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


Re: Possible to override onActivate from an extended page?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 19 Jan 2009 15:02:07 -0300, James Sherwood  
<js...@rgisolutions.com> escreveu:

> My problem:  Is there a way to override the onActivate (or a way around  
> it) in the page that extends SecurePage so I could perform additional  
> security checks?

Short answer: yes, ordinary inheritence works for Tapestry pages too.

Not so short answer: you can have more methods invoked when the page is  
requested:
@OnEvent("activate")
public Object doSomething() { ... }

Long answer: user authentication and other cross-page logic is usually  
better implemented in RequestFilters. Search this mailing list and the  
wiki for examples. :)

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