Search in sources :

Example 11 with Session

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);
}
Also used : Page(org.apache.wicket.Page) DummyPage(org.apache.wicket.resource.DummyPage) WebPage(org.apache.wicket.markup.html.WebPage) Url(org.apache.wicket.request.Url) Session(org.apache.wicket.Session) Test(org.junit.Test)

Example 12 with Session

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));
}
Also used : HttpSession(javax.servlet.http.HttpSession) Session(org.apache.wicket.Session) Test(org.junit.Test)

Example 13 with Session

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;
}
Also used : ISessionStore(org.apache.wicket.session.ISessionStore) IRequestCycle(org.apache.wicket.request.IRequestCycle) Session(org.apache.wicket.Session)

Example 14 with Session

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();
}
Also used : BaseWicketTester(org.apache.wicket.util.tester.BaseWicketTester) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.wicket.Session)

Example 15 with Session

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);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpSession(javax.servlet.http.HttpSession) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.wicket.Session)

Aggregations

Session (org.apache.wicket.Session)16 HttpSession (javax.servlet.http.HttpSession)4 Test (org.junit.Test)4 Locale (java.util.Locale)3 WebPage (org.apache.wicket.markup.html.WebPage)3 WebSession (org.apache.wicket.protocol.http.WebSession)3 Page (org.apache.wicket.Page)2 MockApplication (org.apache.wicket.mock.MockApplication)2 Request (org.apache.wicket.request.Request)2 Response (org.apache.wicket.request.Response)2 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)2 Authentication (org.springframework.security.core.Authentication)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 SecurityContextAwareCallable (com.evolveum.midpoint.web.component.SecurityContextAwareCallable)1 CallableResult (com.evolveum.midpoint.web.component.util.CallableResult)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 CaseWorkItemsPanel (com.evolveum.midpoint.web.page.admin.cases.CaseWorkItemsPanel)1 AsyncDashboardPanel (com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel)1 AccountCallableResult (com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)1 CasesTablePanel (com.evolveum.midpoint.web.page.admin.server.CasesTablePanel)1