Search in sources :

Example 1 with Session

use of org.apache.tapestry5.http.services.Session in project flowlogix by flowlogix.

the class SessionTracker method setSession.

@CleanupRender
private void setSession() {
    if (rg.getRequest().isXHR() == false) {
        Session session = rg.getRequest().getSession(false);
        boolean hasSession = session != null;
        if (hasSession == true) {
            SessionTrackerUtil.setPageSession(rg.getActivePageName(), session);
        }
    }
}
Also used : Session(org.apache.tapestry5.services.Session) CleanupRender(org.apache.tapestry5.annotations.CleanupRender)

Example 2 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class MutableComponentModelImplTest method get_persistent_field_names_reflects_parent_model.

@Test
public void get_persistent_field_names_reflects_parent_model() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel parent = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertEquals(parent.setFieldPersistenceStrategy("wilma", "session"), "wilma");
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, parent, false, null);
    assertEquals(model.setFieldPersistenceStrategy("fred", "session"), "fred");
    assertEquals(model.setFieldPersistenceStrategy("barney", "client"), "barney");
    assertEquals(model.getPersistentFieldNames(), Arrays.asList("barney", "fred", "wilma"));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 3 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class ApplicationStatePersistenceStrategySourceImplTest method strategy_found.

@Test
public void strategy_found() {
    ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy();
    Map<String, ApplicationStatePersistenceStrategy> configuration = Collections.singletonMap("session", strategy);
    replay();
    ApplicationStatePersistenceStrategySource source = new ApplicationStatePersistenceStrategySourceImpl(configuration);
    assertSame(strategy, source.get("session"));
    verify();
}
Also used : ApplicationStatePersistenceStrategySource(org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource) ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) Test(org.testng.annotations.Test)

Example 4 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class MutableComponentModelImplTest method get_persistent_field_names_are_sorted.

@Test
public void get_persistent_field_names_are_sorted() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertEquals(model.setFieldPersistenceStrategy("fred", "session"), "fred");
    assertEquals(model.setFieldPersistenceStrategy("barney", "client"), "barney");
    assertEquals(model.getPersistentFieldNames(), Arrays.asList("barney", "fred"));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 5 with Session

use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.

the class AbstractSessionPersistentFieldStrategy method postChange.

public final void postChange(String pageName, String componentId, String fieldName, Object newValue) {
    assert InternalUtils.isNonBlank(pageName);
    assert InternalUtils.isNonBlank(fieldName);
    Object persistedValue = newValue == null ? null : convertApplicationValueToPersisted(newValue);
    StringBuilder builder = new StringBuilder(prefix);
    builder.append(pageName);
    builder.append(':');
    if (componentId != null)
        builder.append(componentId);
    builder.append(':');
    builder.append(fieldName);
    Session session = request.getSession(persistedValue != null);
    if (session != null) {
        session.setAttribute(builder.toString(), persistedValue);
    }
}
Also used : Session(org.apache.tapestry5.http.services.Session)

Aggregations

Test (org.testng.annotations.Test)31 Session (org.apache.tapestry5.http.services.Session)30 Request (org.apache.tapestry5.http.services.Request)14 HttpSession (javax.servlet.http.HttpSession)10 Logger (org.slf4j.Logger)8 ClusteredSessionImpl (org.apache.tapestry5.http.internal.services.ClusteredSessionImpl)7 Session (org.hibernate.Session)7 SessionImpl (org.apache.tapestry5.http.internal.services.SessionImpl)6 ApplicationStatePersistenceStrategy (org.apache.tapestry5.services.ApplicationStatePersistenceStrategy)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Resource (org.apache.tapestry5.commons.Resource)5 SessionLock (org.apache.tapestry5.http.internal.services.SessionLock)5 MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)5 HibernateEntityValueEncoder (org.apache.tapestry5.hibernate.web.internal.HibernateEntityValueEncoder)4 ReadOnlyBean (org.apache.tapestry5.internal.transform.pages.ReadOnlyBean)4 EntityPersistentFieldStrategy (org.apache.tapestry5.hibernate.web.internal.EntityPersistentFieldStrategy)3 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)3 TapestrySessionFactory (org.apache.tapestry5.http.internal.services.TapestrySessionFactory)3 PersistentFieldChange (org.apache.tapestry5.services.PersistentFieldChange)3 Enumeration (java.util.Enumeration)2