You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jeff Emminger <je...@jeffemminger.com> on 2003/11/24 16:50:52 UTC

conditionally displaying a page if logged in

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


Re: conditionally displaying a page if logged in

Posted by Jeff Emminger <je...@jeffemminger.com>.
you're right about the signature - fixed that, but still not working as 
(i think) it should.  I can still link to SomePage without being 
redirected...i've even changed pageValidate() to this without success:

public void pageValidate(PageEvent event) {
	throw new PageRedirectException("Home");
}





Paul Ferraro wrote:

> Oops - I think I gave you the wrong method signature.... It should be:
> 
> public void pageValidate(PageEvent pageEvent)
> 
> That will fix your compilation issue.
> 
> Paul
> 
> Jeff Emminger wrote:
> 
>> hi Len,
>>
>> I tried implementing PageValidateListener per Paul Ferraro's example:
>>
>> public class SomePage extends BasePage implements PageValidateListener {
>>     Visit visit = (Visit)getVisit();
>>
>>     public void pageValidate(IRequestCycle cycle) {
>>         if (true) {
>>             visit.setError("Please log in.");
>>             Home home = (Home)cycle.getPage("Home");
>>             throw new PageRedirectException(home);
>>         }
>>     }
>> }
>>
>>
>> ...but eclipse won't compile, telling me that i have to implement the 
>> inherited abstract method pageValidate() when it's already there!
>>
>>
>> Marilen Corciovei wrote:
>>
>>> Should you not implement the PageValidateListener?
>>>
>>> Len
>>>
>>> On Mon, 2003-11-24 at 23:36, Jeff Emminger wrote:
>>>
>>>
>>>> ok, based on the vlib example, i've done this for my protected page 
>>>> SomePage:
>>>>
>>>> public class SomePage extends BasePage {
>>>>     Visit visit = (Visit)getVisit();
>>>>
>>>>     public void validate(IRequestCycle cycle)
>>>>     throws PageRedirectException {
>>>>         if (true) {
>>>>             visit.setError("Please log in.");
>>>>             Home home = (Home)cycle.getPage("Home");
>>>>             throw new PageRedirectException(home);
>>>>         }
>>>>     }
>>>> }
>>>>
>>>>
>>>> right now i'm trying to force the redirect by using "if (true)", but 
>>>> i still get SomePage instead of being redirected back to Home.  any 
>>>> takers?
>>>>
>>>> additionally, i may be using the Visit wrong, since i can't seem to 
>>>> set the error message.
>>>>
>>>> Visit.java:
>>>> public class Visit implements Serializable {
>>>>     private String username = "";
>>>>     private String error = "";
>>>>         public String getUsername() {
>>>>         return this.username;
>>>>     }
>>>>     public void setUsername(String username) {
>>>>         this.username = username;
>>>>     }
>>>>         public String getError() {
>>>>         return this.error;
>>>>     }
>>>>     public void setError(String error) {
>>>>         this.error = error;
>>>>     }
>>>>     public boolean getHasError() {
>>>>         return this.getError().length() > 0;
>>>>     }
>>>> }
>>>>
>>>> Home.java:
>>>> public class Home extends BasePage {
>>>>     private String username = "";
>>>>         public String getUsername() {
>>>>         return this.username;
>>>>     }
>>>>     public void setUsername(String username) {
>>>>         this.username = username;
>>>>     }
>>>>     public void formSubmit(IRequestCycle cycle) {               if 
>>>> (getUsername() != null) {
>>>>             Visit visit = (Visit)getVisit();
>>>>             visit.setUsername( getUsername() );
>>>>             cycle.activate("SomePage");
>>>>         }
>>>>     }
>>>> }
>>>>
>>>>
>>>>
>>>> John Meredith wrote:
>>>>
>>>>
>>>>> Hi Jeff,
>>>>>
>>>>> Have a look at the vlib example of ProtectedPage which implements
>>>>> PageValidateListener.
>>>>>
>>>>> You can then do all your authentication in the validate() method and
>>>>> redirect to an appropriate page if login (or other permissions) are
>>>>> required.
>>>>>
>>>>>  - John
>>>>>
>>>>> On Mon, 2003-11-24 at 16:50, 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
> 
> 



---------------------------------------------------------------------
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 if logged in

Posted by Paul Ferraro <pm...@columbia.edu>.
Oops - I think I gave you the wrong method signature.... It should be:

public void pageValidate(PageEvent pageEvent)

That will fix your compilation issue.

Paul

Jeff Emminger wrote:

> hi Len,
>
> I tried implementing PageValidateListener per Paul Ferraro's example:
>
> public class SomePage extends BasePage implements PageValidateListener {
>     Visit visit = (Visit)getVisit();
>
>     public void pageValidate(IRequestCycle cycle) {
>         if (true) {
>             visit.setError("Please log in.");
>             Home home = (Home)cycle.getPage("Home");
>             throw new PageRedirectException(home);
>         }
>     }
> }
>
>
> ...but eclipse won't compile, telling me that i have to implement the 
> inherited abstract method pageValidate() when it's already there!
>
>
> Marilen Corciovei wrote:
>
>> Should you not implement the PageValidateListener?
>>
>> Len
>>
>> On Mon, 2003-11-24 at 23:36, Jeff Emminger wrote:
>>
>>
>>> ok, based on the vlib example, i've done this for my protected page 
>>> SomePage:
>>>
>>> public class SomePage extends BasePage {
>>>     Visit visit = (Visit)getVisit();
>>>
>>>     public void validate(IRequestCycle cycle)
>>>     throws PageRedirectException {
>>>         if (true) {
>>>             visit.setError("Please log in.");
>>>             Home home = (Home)cycle.getPage("Home");
>>>             throw new PageRedirectException(home);
>>>         }
>>>     }
>>> }
>>>
>>>
>>> right now i'm trying to force the redirect by using "if (true)", but 
>>> i still get SomePage instead of being redirected back to Home.  any 
>>> takers?
>>>
>>> additionally, i may be using the Visit wrong, since i can't seem to 
>>> set the error message.
>>>
>>> Visit.java:
>>> public class Visit implements Serializable {
>>>     private String username = "";
>>>     private String error = "";
>>>     
>>>     public String getUsername() {
>>>         return this.username;
>>>     }
>>>     public void setUsername(String username) {
>>>         this.username = username;
>>>     }
>>>     
>>>     public String getError() {
>>>         return this.error;
>>>     }
>>>     public void setError(String error) {
>>>         this.error = error;
>>>     }
>>>     public boolean getHasError() {
>>>         return this.getError().length() > 0;
>>>     }
>>> }
>>>
>>> Home.java:
>>> public class Home extends BasePage {
>>>     private String username = "";
>>>     
>>>     public String getUsername() {
>>>         return this.username;
>>>     }
>>>     public void setUsername(String username) {
>>>         this.username = username;
>>>     }
>>>     public void formSubmit(IRequestCycle cycle) {       
>>>         if (getUsername() != null) {
>>>             Visit visit = (Visit)getVisit();
>>>             visit.setUsername( getUsername() );
>>>             cycle.activate("SomePage");
>>>         }
>>>     }
>>> }
>>>
>>>
>>>
>>> John Meredith wrote:
>>>
>>>
>>>> Hi Jeff,
>>>>
>>>> Have a look at the vlib example of ProtectedPage which implements
>>>> PageValidateListener.
>>>>
>>>> You can then do all your authentication in the validate() method and
>>>> redirect to an appropriate page if login (or other permissions) are
>>>> required.
>>>>
>>>>  - John
>>>>
>>>> On Mon, 2003-11-24 at 16:50, 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


Re: conditionally displaying a page if logged in

Posted by Jeff Emminger <je...@jeffemminger.com>.
hi Len,

I tried implementing PageValidateListener per Paul Ferraro's example:

public class SomePage extends BasePage implements PageValidateListener {
	Visit visit = (Visit)getVisit();

	public void pageValidate(IRequestCycle cycle) {
		if (true) {
			visit.setError("Please log in.");
			Home home = (Home)cycle.getPage("Home");
			throw new PageRedirectException(home);
		}
	}
}


...but eclipse won't compile, telling me that i have to implement the 
inherited abstract method pageValidate() when it's already there!


Marilen Corciovei wrote:

> Should you not implement the PageValidateListener?
> 
> Len
> 
> On Mon, 2003-11-24 at 23:36, Jeff Emminger wrote:
> 
> 
>>ok, based on the vlib example, i've done this for my protected page 
>>SomePage:
>>
>>public class SomePage extends BasePage {
>>	Visit visit = (Visit)getVisit();
>>
>>	public void validate(IRequestCycle cycle)
>>	throws PageRedirectException {
>>		if (true) {
>>			visit.setError("Please log in.");
>>			Home home = (Home)cycle.getPage("Home");
>>			throw new PageRedirectException(home);
>>		}
>>	}
>>}
>>
>>
>>right now i'm trying to force the redirect by using "if (true)", but i 
>>still get SomePage instead of being redirected back to Home.  any takers?
>>
>>additionally, i may be using the Visit wrong, since i can't seem to set 
>>the error message.
>>
>>Visit.java:
>>public class Visit implements Serializable {
>>	private String username = "";
>>	private String error = "";
>>	
>>	public String getUsername() {
>>		return this.username;
>>	}
>>	public void setUsername(String username) {
>>		this.username = username;
>>	}
>>	
>>	public String getError() {
>>		return this.error;
>>	}
>>	public void setError(String error) {
>>		this.error = error;
>>	}
>>	public boolean getHasError() {
>>		return this.getError().length() > 0;
>>	}
>>}
>>
>>Home.java:
>>public class Home extends BasePage {
>>	private String username = "";
>>	
>>	public String getUsername() {
>>		return this.username;
>>	}
>>	public void setUsername(String username) {
>>		this.username = username;
>>	}
>>	public void formSubmit(IRequestCycle cycle) {		
>>		if (getUsername() != null) {
>>			Visit visit = (Visit)getVisit();
>>			visit.setUsername( getUsername() );
>>			cycle.activate("SomePage");
>>		}
>>	}
>>}
>>
>>
>>
>>John Meredith wrote:
>>
>>
>>>Hi Jeff,
>>>
>>>Have a look at the vlib example of ProtectedPage which implements
>>>PageValidateListener.
>>>
>>>You can then do all your authentication in the validate() method and
>>>redirect to an appropriate page if login (or other permissions) are
>>>required.
>>>
>>>  - John
>>>
>>>On Mon, 2003-11-24 at 16:50, 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 if logged in

Posted by Marilen Corciovei <le...@nemesisit.rdsnet.ro>.
Should you not implement the PageValidateListener?

Len

On Mon, 2003-11-24 at 23:36, Jeff Emminger wrote:

> ok, based on the vlib example, i've done this for my protected page 
> SomePage:
> 
> public class SomePage extends BasePage {
> 	Visit visit = (Visit)getVisit();
> 
> 	public void validate(IRequestCycle cycle)
> 	throws PageRedirectException {
> 		if (true) {
> 			visit.setError("Please log in.");
> 			Home home = (Home)cycle.getPage("Home");
> 			throw new PageRedirectException(home);
> 		}
> 	}
> }
> 
> 
> right now i'm trying to force the redirect by using "if (true)", but i 
> still get SomePage instead of being redirected back to Home.  any takers?
> 
> additionally, i may be using the Visit wrong, since i can't seem to set 
> the error message.
> 
> Visit.java:
> public class Visit implements Serializable {
> 	private String username = "";
> 	private String error = "";
> 	
> 	public String getUsername() {
> 		return this.username;
> 	}
> 	public void setUsername(String username) {
> 		this.username = username;
> 	}
> 	
> 	public String getError() {
> 		return this.error;
> 	}
> 	public void setError(String error) {
> 		this.error = error;
> 	}
> 	public boolean getHasError() {
> 		return this.getError().length() > 0;
> 	}
> }
> 
> Home.java:
> public class Home extends BasePage {
> 	private String username = "";
> 	
> 	public String getUsername() {
> 		return this.username;
> 	}
> 	public void setUsername(String username) {
> 		this.username = username;
> 	}
> 	public void formSubmit(IRequestCycle cycle) {		
> 		if (getUsername() != null) {
> 			Visit visit = (Visit)getVisit();
> 			visit.setUsername( getUsername() );
> 			cycle.activate("SomePage");
> 		}
> 	}
> }
> 
> 
> 
> John Meredith wrote:
> 
> > Hi Jeff,
> > 
> > Have a look at the vlib example of ProtectedPage which implements
> > PageValidateListener.
> > 
> > You can then do all your authentication in the validate() method and
> > redirect to an appropriate page if login (or other permissions) are
> > required.
> > 
> >   - John
> > 
> > On Mon, 2003-11-24 at 16:50, 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



Re: conditionally displaying a page if logged in

Posted by Jeff Emminger <je...@jeffemminger.com>.
ok, based on the vlib example, i've done this for my protected page 
SomePage:

public class SomePage extends BasePage {
	Visit visit = (Visit)getVisit();

	public void validate(IRequestCycle cycle)
	throws PageRedirectException {
		if (true) {
			visit.setError("Please log in.");
			Home home = (Home)cycle.getPage("Home");
			throw new PageRedirectException(home);
		}
	}
}


right now i'm trying to force the redirect by using "if (true)", but i 
still get SomePage instead of being redirected back to Home.  any takers?

additionally, i may be using the Visit wrong, since i can't seem to set 
the error message.

Visit.java:
public class Visit implements Serializable {
	private String username = "";
	private String error = "";
	
	public String getUsername() {
		return this.username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	
	public String getError() {
		return this.error;
	}
	public void setError(String error) {
		this.error = error;
	}
	public boolean getHasError() {
		return this.getError().length() > 0;
	}
}

Home.java:
public class Home extends BasePage {
	private String username = "";
	
	public String getUsername() {
		return this.username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public void formSubmit(IRequestCycle cycle) {		
		if (getUsername() != null) {
			Visit visit = (Visit)getVisit();
			visit.setUsername( getUsername() );
			cycle.activate("SomePage");
		}
	}
}



John Meredith wrote:

> Hi Jeff,
> 
> Have a look at the vlib example of ProtectedPage which implements
> PageValidateListener.
> 
> You can then do all your authentication in the validate() method and
> redirect to an appropriate page if login (or other permissions) are
> required.
> 
>   - John
> 
> On Mon, 2003-11-24 at 16:50, 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


Re: conditionally displaying a page if logged in

Posted by John Meredith <ps...@t-online.de>.
Hi Jeff,

Have a look at the vlib example of ProtectedPage which implements
PageValidateListener.

You can then do all your authentication in the validate() method and
redirect to an appropriate page if login (or other permissions) are
required.

  - John

On Mon, 2003-11-24 at 16:50, 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
-- 
John Meredith <ps...@t-online.de>


---------------------------------------------------------------------
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 if logged in

Posted by Paul Ferraro <pm...@columbia.edu>.
If your using Tapestry v3.0, it is recommended that your page implement 
org.apache.tapestry.event.PageValidateListener:

public class MyObject implements PageValidateListener
{
    public void pageValidate(IRequestCycle requestCycle)
    {
        // Your logic
    }
}

This is event will be triggered from the IPage.validate() method.

Paul Ferraro

Kevin C. Dorff wrote:

> 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 if logged in

Posted by "Kevin C. Dorff" <kd...@kcp.com>.
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