Liu,

My solution is to patch org.apache.tapestry.portlet.PortletRendererImpl
to catch PageRedirectException thrown during renderPage():

public void renderPage(IRequestCycle cycle, String pageName) throws IOException
{
    try {

        cycle.activate(pageName);
        
        ...

        writer.close();

    } catch (PageRedirectException e) {
        handlePageRedirectException(cycle, e);
    }
}

protected void handlePageRedirectException(IRequestCycle cycle, 
PageRedirectException exception)
throws IOException
{
        List pageNames = new ArrayList();
                
        String pageName = exception.getTargetPageName();
                
        while (true)
        {
            if (pageNames.contains(pageName))
            {
                pageNames.add(pageName);
        
                throw new ApplicationRuntimeException("Page redirect cycle 
detected");
            }
                
            // Record that this page has been a target.
                
            pageNames.add(pageName);
                
            try
            {
                // Attempt to activate the new page.
                
                cycle.activate(pageName);
                
                break;
            }
            catch (PageRedirectException secondRedirectException)
            {
                pageName = secondRedirectException.getTargetPageName();
            }
        }
                
        renderPage(cycle, pageName);
}

Hope this helps,

Raphael Jean
EntropySoft

> -----Original Message-----
> From: Liu Yan [mailto:[EMAIL PROTECTED]
> Sent: mercredi 25 janvier 2006 14:25
> To: Tapestry users
> Subject: Re: PageRedirectException throws a NullPointerException in a
> Portlet
> 
> hi Raphael,
> 
> What's your solution to this problem?
> 
> Regards,
> Liu Yan
> 
> 
> ----- Original Message -----
> From: "Raphaël Jean" <[EMAIL PROTECTED]>
> To: "Tapestry users" <[email protected]>
> Sent: Wednesday, January 25, 2006 6:26 PM
> Subject: RE: PageRedirectException throws a NullPointerException in a
> Portlet
> 
> 
> Hi Liu,
> 
> I encountered the same problem. Unfortunately, you cannot throw a
> PageRedirectException when rendering a portlet page. This can only be done
> in a listener or during form rewind (that is, during portlet action
> processing).
> 
> Raphael Jean
> EntropySoft
> 
> > -----Original Message-----
> > From: Liu Yan [mailto:[EMAIL PROTECTED]
> > Sent: mercredi 25 janvier 2006 07:58
> > To: Tapestry users
> > Subject: PageRedirectException throws a NullPointerException in a
> Portlet
> >
> > hi,
> >
> > I am using JBoss Portlet 2.2 plus T4 based portlet. What I am trying to
> do
> > is to control the display of a Login form in a portlet. My idea is
> having
> > a
> > Login page with username and password input fields, and an Empty page
> > displays nothing. In the Login's pageValidate() method, I will throw out
> a
> > PageRedirectException to redirect to the Empty page in case the user
> > already
> > logged in.
> >
> > However, I got the following exception, which I think probably this is
> not
> > the right approach:
> >
> >  java.lang.NullPointerException
> > Property 'actionResponse' of <OuterProxy for
> > tapestry.portlet.PortletRequestGlobals(
> > org.apache.tapestry.portlet.PortletRequestGlobals)> is null.
> >
> > Any ideas on this?
> >
> > Regards,
> > Liu Yan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to