You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mark Stang <ms...@pingidentity.com> on 2005/03/28 17:10:22 UTC

Validate Question

All,
I have been going through Kent's tutorials, which are excellent.  In the eShop tutorial, he uses the validate method to determine if someone is logged in.

	public void validate(IRequestCycle cycle) {
		super.validate(cycle);
		Visit visit = (Visit) getVisit();
		User loggedInUser = visit.getLoggedInUser();
		if (loggedInUser == null) 
		{
			Login login = (Login) cycle.getPage("Login");
			login.setNextPage(new PageCallback(this));
			throw new PageRedirectException(login);
		}
	}

However, it appears that in order for this to work, the validate method must be called before the page is displayed, which it is.  However, it is also called when leaving the page it seems.  Or at least the breakpoints in the debugger indicated that was what was happening.

Is it true that the validate method of BasePage is called both times?  And how do we determine which one it is?

thanks,

Mark


Re: Validate Question

Posted by Kent Tong <ke...@cpttm.org.mo>.
Mark Stang <mstang <at> pingidentity.com> writes:

> However, it appears that in order for this to work, the validate method must
> be called before the page is
> displayed, which it is.  However, it is also called when leaving the page it 
> seems.  Or at least the
> breakpoints in the debugger indicated that was what was happening.
> 
> Is it true that the validate method of BasePage is called both times?  And 
> how do we determine which one it is?

It should not be called when "leaving the page", unless what
you mean by that is "activating the page". If this is indeed
the case, how does it bother you?



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