Thanks - that's the path I went down after i posted.  Didn't know if there
was a cleaner way or not.

igor.vaynberg wrote:
> 
> requestcycle rc=getrequestcycle();
> 
> response orig=rc.getresponse();
> rc.setresponse(new noopresponse());
> page.render();
> rc.setresponse(orig);
> 
> -igor
> 
> On Wed, Feb 4, 2009 at 2:10 PM, sthomps <stho...@gmail.com> wrote:
>>
>> I'm running into an issue with PageExpiredExceptions and ajax responses.
>>
>> Here's what I would like to do.
>>
>> 1.  Have sessions timeout at 20 minutes.
>> 2.  Once a session has timed out and the user clicks an ajax link on the
>> expired page - the link should process as normal and do whatever was tied
>> to
>> that link - such as show a modal window.
>>
>> Here's what I have so far.  The ajax link works but the returned response
>> is
>> the entire page + whatever component was added to the AjaxRequestTarget -
>> because of the Page.render() I would assume.  It's starting to feel like
>> more of a hack and I'm pretty sure there's a better way to do this.
>>
>>
>> public class MyWebRequestCycleProcessor extends WebRequestCycleProcessor
>> {
>>        protected IRequestTarget resolveRenderedPage(RequestCycle
>> requestCycle,
>> RequestParameters requestParameters)
>>        {
>>                String componentPath =
>> requestParameters.getComponentPath();
>>                Session session = requestCycle.getSession();
>>                Page page =
>> session.getPage(requestParameters.getPageMapName(),
>> componentPath, requestParameters.getVersionNumber());
>>                if (page != null)
>>                {
>>                        return resolveRenderedPage(requestCycle,
>> requestParameters, page, false);
>>                }
>>                else
>>                {
>>                        // Try to resolve the page instead of throwing an
>> expired page exception
>>                        try
>>                        {
>>                                page = newPage(requestCycle,
>> requestParameters);
>>                                if (page != null)
>>                                {
>>                                        IPageMap pageMap =
>> PageMap.forName(requestParameters.getPageMapName());
>>                                        pageMap.put(page);
>>                                        return
>> resolveRenderedPage(requestCycle, requestParameters, page,
>> true);
>>                                }
>>                        }
>>                        catch (Exception e)
>>                        {
>>                                LOG.error(e.getMessage(), e);
>>                        }
>>                }
>>                return null;
>>        }
>>
>>        protected Page newPage(RequestCycle requestCycle,
>> RequestParameters
>> requestParameters) throws Exception
>>        {
>>                PageParameters params = new
>> PageParameters(requestParameters.getParameters());
>>                IPageFactory pageFactory =
>> requestCycle.getApplication().getSessionSettings().getPageFactory();
>>                if ((params == null) || (params.size() == 0))
>>                {
>>                        return
>> pageFactory.newPage(Class.forName(requestParameters.getPageMapName()));
>>                }
>>                else
>>                {
>>                       
>> requestCycle.getRequest().getParameterMap().putAll(((params)));
>>                        return
>> pageFactory.newPage(Class.forName(requestParameters.getPageMapName()),
>> params);
>>                }
>>        }
>>
>>        private IRequestTarget resolveRenderedPage(RequestCycle
>> requestCycle,
>> RequestParameters requestParameters, Page page, boolean newRequest)
>>        {
>>                IRequestTarget target = null;
>>
>>                requestCycle.getRequest().setPage(page);
>>                String interfaceName =
>> requestParameters.getInterfaceName();
>>                String componentPath =
>> requestParameters.getComponentPath();
>>                MyAjaxMarkupContainer container = null;
>>                if (newRequest)
>>                {
>>                        if (componentPath.indexOf("ajax_link") != -1)
>>                        {
>>                                container = ((MyPage)
>> page).getMyAjaxMarkupContainer();
>>                        }
>>                        // needed for wicket to find the ajax link to make
>> the request
>>                        container.beforeRender();
>>
>>                        // Render the page so wicket finds the markup for
>> the ajax link making
>> the request
>>                        page.render();
>>                        page.afterRender();
>>                }
>>                if (interfaceName != null)
>>                {
>>                        target =
>> resolveListenerInterfaceTarget(requestCycle, page,
>> componentPath, interfaceName, requestParameters);
>>                }
>>                else
>>                {
>>                        target = ((new PageRequestTarget(page)));
>>                }
>>
>>                return target;
>>        }
>> }
>> --
>> View this message in context:
>> http://www.nabble.com/PageExpiredException---ajax-request-tp21840751p21840751.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/PageExpiredException---ajax-request-tp21840751p21844874.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to