You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christopher Corde <cc...@yahoo.com> on 2004/01/23 22:16:02 UTC

Why does cycle.activate() not work sometimes?

Hey,

  I have a two part question. I am adding session
management to my site, and I'm having trouble
redirecting to the login page. Here is my code:

public void pageBeginRender(PageEvent e) {
  tapestryLogger.debug("Page begin render. Checking
access.");		
  Visit visit = (Visit) this.getVisit();
  if (!visit.checkAccess()) {
    tapestryLogger.debug("User not logged in.");
    LoginPage login = (LoginPage)
this.getRequestCycle().getPage("LoginPage");
    login.setReferringPage(this);
    this.getRequestCycle().activate(login);
  }
}

The activate call does nothing. I have seen this
before, but I have also seen activate work perfectly
before. Is there a reason it is not working?

Also, I used a cheat to workaround this by throwing a
PageRedirectException(login). However, when the login
page cycles back to the Home (using activate(), by the
way), I get a NullPointerException in the
this.getVisit(); call. Any ideas why that would
happen? It worked fine the first time through, before
the redirect to the LoginPage.

Thanks,
Chris


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


RE: Why does cycle.activate() not work sometimes?

Posted by Christopher Corde <cc...@yahoo.com>.
Thanks for the help.

I logged bug 26387 regarding this.

--- "Howard M. Lewis Ship" <hl...@comcast.net> wrote:
> pageBeginRender() is too late to change the active
> page.
> 
> Your page could implement PageValidateListener and
> the pageValidate() method and throw a
> PageRedirectException.
> 
> Please add a bug; activate() should throw an
> exception when it is called at an inappropriate
> time.
> 
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components 
> http://jakarta.apache.org/tapestry/
> http://javatapestry.blogspot.com
> 
> > -----Original Message-----
> > From: Christopher Corde
> [mailto:ccorde01@yahoo.com] 
> > Sent: Friday, January 23, 2004 4:16 PM
> > To: Tapestry
> > Subject: Why does cycle.activate() not work
> sometimes?
> > 
> > 
> > Hey,
> > 
> >   I have a two part question. I am adding session
> > management to my site, and I'm having trouble
> > redirecting to the login page. Here is my code:
> > 
> > public void pageBeginRender(PageEvent e) {
> >   tapestryLogger.debug("Page begin render.
> Checking
> > access.");		
> >   Visit visit = (Visit) this.getVisit();
> >   if (!visit.checkAccess()) {
> >     tapestryLogger.debug("User not logged in.");
> >     LoginPage login = (LoginPage)
> > this.getRequestCycle().getPage("LoginPage");
> >     login.setReferringPage(this);
> >     this.getRequestCycle().activate(login);
> >   }
> > }
> > 
> > The activate call does nothing. I have seen this
> > before, but I have also seen activate work
> perfectly
> > before. Is there a reason it is not working?
> > 
> > Also, I used a cheat to workaround this by
> throwing a
> > PageRedirectException(login). However, when the
> login
> > page cycles back to the Home (using activate(), by
> the
> > way), I get a NullPointerException in the
> > this.getVisit(); call. Any ideas why that would
> > happen? It worked fine the first time through,
> before
> > the redirect to the LoginPage.
> > 
> > Thanks,
> > Chris
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free web site building tool.
> Try it!
> > http://webhosting.yahoo.com/ps/sb/
> > 
> >
>
---------------------------------------------------------------------
> > 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
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


RE: Why does cycle.activate() not work sometimes?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
pageBeginRender() is too late to change the active page.

Your page could implement PageValidateListener and the pageValidate() method and throw a
PageRedirectException.

Please add a bug; activate() should throw an exception when it is called at an inappropriate time.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Christopher Corde [mailto:ccorde01@yahoo.com] 
> Sent: Friday, January 23, 2004 4:16 PM
> To: Tapestry
> Subject: Why does cycle.activate() not work sometimes?
> 
> 
> Hey,
> 
>   I have a two part question. I am adding session
> management to my site, and I'm having trouble
> redirecting to the login page. Here is my code:
> 
> public void pageBeginRender(PageEvent e) {
>   tapestryLogger.debug("Page begin render. Checking
> access.");		
>   Visit visit = (Visit) this.getVisit();
>   if (!visit.checkAccess()) {
>     tapestryLogger.debug("User not logged in.");
>     LoginPage login = (LoginPage)
> this.getRequestCycle().getPage("LoginPage");
>     login.setReferringPage(this);
>     this.getRequestCycle().activate(login);
>   }
> }
> 
> The activate call does nothing. I have seen this
> before, but I have also seen activate work perfectly
> before. Is there a reason it is not working?
> 
> Also, I used a cheat to workaround this by throwing a
> PageRedirectException(login). However, when the login
> page cycles back to the Home (using activate(), by the
> way), I get a NullPointerException in the
> this.getVisit(); call. Any ideas why that would
> happen? It worked fine the first time through, before
> the redirect to the LoginPage.
> 
> Thanks,
> Chris
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
> 
> ---------------------------------------------------------------------
> 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