Re: PageExpiredException - ajax request

2010-08-11 Thread sbrookes2

Is it possible to restore a page once it has been removed from the PageMap? 
It seems to be possible based on this thread but so far I haven't been able
to work it out.

In the above code:
return
pageFactory.newPage(Class.forName(requestParameters.getPageMapName()),
params);

When I try to generate the page it returns null because the default PageMap
name is null.  What am I missing?


Also, forgive another dumb question but Igor I have been trying to figure
out where the pseudo-code you posted should go in the request cycle but so
far am lost.  Can you provide a few more details?
requestcycle rc=getrequestcycle(); 

response orig=rc.getresponse(); 
rc.setresponse(new noopresponse()); 
page.render(); 
rc.setresponse(orig); 

thanks,
Sean 
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PageExpiredException-ajax-request-tp1878866p2321861.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



Re: PageExpiredException - ajax request

2010-07-02 Thread sbrookes2


igor.vaynberg wrote:
 
 requestcycle rc=getrequestcycle();
 
 response orig=rc.getresponse();
 rc.setresponse(new noopresponse());
 page.render();
 rc.setresponse(orig);
 
 -igor
 

This may be a silly question but can you shed some light on the line:
rc.setresponse(new noopresponse());

Specifically the reference to noopresponse.  Is that a reference to an
existing method in Wicket or something that needs to be written for the
solution?  I get the general gist of the proposal but am a little confused
by what this line is intended to to.

thanks,
sean
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PageExpiredException-ajax-request-tp1878866p2277019.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



Re: PageExpiredException - ajax request

2010-07-02 Thread Igor Vaynberg
org.apache.wicket.response.NullResponse

-igor

On Fri, Jul 2, 2010 at 5:38 PM, sbrookes2 seanbroo...@shaw.ca wrote:


 igor.vaynberg wrote:

 requestcycle rc=getrequestcycle();

 response orig=rc.getresponse();
 rc.setresponse(new noopresponse());
 page.render();
 rc.setresponse(orig);

 -igor


 This may be a silly question but can you shed some light on the line:
 rc.setresponse(new noopresponse());

 Specifically the reference to noopresponse.  Is that a reference to an
 existing method in Wicket or something that needs to be written for the
 solution?  I get the general gist of the proposal but am a little confused
 by what this line is intended to to.

 thanks,
 sean
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/PageExpiredException-ajax-request-tp1878866p2277019.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



PageExpiredException - ajax request

2009-02-04 Thread sthomps

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



Re: PageExpiredException - ajax request

2009-02-04 Thread Igor Vaynberg
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

Re: PageExpiredException - ajax request

2009-02-04 Thread sthomps

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