You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Cox, Jason" <ja...@citigroup.com> on 2003/11/24 17:04:45 UTC

RE: conditionally displaying a page- derail

What's the penalty for not having Home subclassed from BasePage?

Right now I have my HomePage class inheriting from WebPage which itself
inherits from BasePage. Wouldn't it still be considered a type of BasePage?

I did this because there is some common logic used in most of my
"user-facing" pages (non-content management) that I don't want to recreate
in every class.

-----Original Message-----
From: Kevin C. Dorff [mailto:kdorff@kcp.com]
Sent: Monday, November 24, 2003 9:58 AM
To: Tapestry users
Subject: Re: conditionally displaying a page if logged in


Override validate, such as

   public void validate(IRequestCycle cycle) {
      super.validate(cycle);
      //your logic
   }

Note that the page you are calling "Home" should be derived from 
BasePage and not SomePage. All of your other pages should be derived 
from SomePage.

Kevin
       

Jeff Emminger wrote:

> i'm trying to build an example of an app that requires you to log 
> in...my current idea is to store the username in the visit, and the 
> presence or absence of the username determines "logged in" or not.
>
> in the page that should be restricted to logged in users (SomePage), i 
> check the visit for the username in SomePage's initialize() method and 
> attempt to throw a PageRedirectException to Home if no username.  this 
> doesn't seem to work, as it never redirects...what should i be doing?
>
> SomePage.java:
> public class SomePage extends BasePage {
>     Visit visit = (Visit)getVisit();
>     
>     protected void initialize() {
>         if (visit.getUsername().length() == 0) {
>             visit.setError("Please log in.");
>             throw new PageRedirectException("Home");
>         }
>     }
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>




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

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


Re: conditionally displaying a page- derail

Posted by "Kevin C. Dorff" <kd...@kcp.com>.
All I meant was that the class has a parent somewhere in its ancestry of 
BasePage. How I do it is, essentially,

<most pages> are of type SecurePage, which extends BasePage
<login page> is of type BaseBage

The validate() of SecurePage.java checks if the user isn't appropriately 
validated and will steer the user to <login page>.

<login page> isn't a SecurePage so it avoids the "valid user" lookup 
logic, just shows the login.

Makes up?
Kevin

Cox, Jason wrote:

>What's the penalty for not having Home subclassed from BasePage?
>
>Right now I have my HomePage class inheriting from WebPage which itself
>inherits from BasePage. Wouldn't it still be considered a type of BasePage?
>
>I did this because there is some common logic used in most of my
>"user-facing" pages (non-content management) that I don't want to recreate
>in every class.
>
>-----Original Message-----
>From: Kevin C. Dorff [mailto:kdorff@kcp.com]
>Sent: Monday, November 24, 2003 9:58 AM
>To: Tapestry users
>Subject: Re: conditionally displaying a page if logged in
>
>
>Override validate, such as
>
>   public void validate(IRequestCycle cycle) {
>      super.validate(cycle);
>      //your logic
>   }
>
>Note that the page you are calling "Home" should be derived from 
>BasePage and not SomePage. All of your other pages should be derived 
>from SomePage.
>
>Kevin
>       
>
>Jeff Emminger wrote:
>
>  
>
>>i'm trying to build an example of an app that requires you to log 
>>in...my current idea is to store the username in the visit, and the 
>>presence or absence of the username determines "logged in" or not.
>>
>>in the page that should be restricted to logged in users (SomePage), i 
>>check the visit for the username in SomePage's initialize() method and 
>>attempt to throw a PageRedirectException to Home if no username.  this 
>>doesn't seem to work, as it never redirects...what should i be doing?
>>
>>SomePage.java:
>>public class SomePage extends BasePage {
>>    Visit visit = (Visit)getVisit();
>>    
>>    protected void initialize() {
>>        if (visit.getUsername().length() == 0) {
>>            visit.setError("Please log in.");
>>            throw new PageRedirectException("Home");
>>        }
>>    }
>>}
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>




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