use of org.apache.wicket.Session in project wicket by apache.
the class ListenerRequestHandlerTest method recreateThePageWhenListenereInterfaceIsExecutedOnExpiredPage.
/**
* https://issues.apache.org/jira/browse/WICKET-4116
*
* @throws Exception
*/
@Test
public void recreateThePageWhenListenereInterfaceIsExecutedOnExpiredPage() throws Exception {
tester.getApplication().mountPage("ajaxLink", AjaxLinkExpirePage.class);
AjaxLinkExpirePage page = tester.startPage(AjaxLinkExpirePage.class);
int initialPageId = page.getPageId();
Url urlToAjaxLink = tester.urlFor(page.link);
Session session = tester.getSession();
session.clear();
// fire a request to the ajax link on the expired page
executeAjaxUrlWithLastBaseUrl(urlToAjaxLink);
Page lastRenderedPage = tester.getLastRenderedPage();
int lastRenderedPageId = lastRenderedPage.getPageId();
assertTrue("A new page must be create ", lastRenderedPageId > initialPageId);
}
use of org.apache.wicket.Session in project wicket by apache.
the class MockHttpServletRequestTest method setLocale.
@Test
public void setLocale() {
Session session = tester.getSession();
session.setLocale(Locale.US);
tester.getRequest().setLocale(Locale.CANADA_FRENCH);
session.invalidateNow();
assertThat(tester.getSession().getLocale(), is(Locale.CANADA_FRENCH));
}
use of org.apache.wicket.Session in project wicket by apache.
the class BufferedResponseMapper method getSessionId.
/**
* @return the current session id for stateful pages and <code>null</code> for stateless pages
* and non-http threads
*/
protected String getSessionId() {
String sessionId = null;
if (Application.exists() && RequestCycle.get() != null) {
ISessionStore sessionStore = Application.get().getSessionStore();
IRequestCycle requestCycle = RequestCycle.get();
Session session = sessionStore.lookup(requestCycle.getRequest());
if (session != null) {
sessionId = session.getId();
}
}
return sessionId;
}
use of org.apache.wicket.Session in project wicket by apache.
the class MockHttpSession method invalidate.
/**
* Invalidate the session.
*/
@Override
public void invalidate() {
Session session = (Session) attributes.get("wicket:" + BaseWicketTester.TestFilterConfig.class.getName() + ":session");
if (session != null) {
session.onInvalidate();
}
attributes.clear();
id = generateSessionId();
}
use of org.apache.wicket.Session in project wicket by apache.
the class WicketSessionFilter method bindSession.
private void bindSession(ServletRequest request, WebApplication application) {
// find wicket session and bind it to thread
HttpSession httpSession = ((HttpServletRequest) request).getSession(false);
Session session = getSession(httpSession, application);
if (session == null) {
if (logger.isDebugEnabled()) {
logger.debug("could not set Wicket session: key " + sessionKey + " not found in http session for " + ((HttpServletRequest) request).getContextPath() + "," + request.getServerName() + ", or http session does not exist");
}
} else {
ThreadContext.setSession(session);
}
}
Aggregations