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);
}
}
}
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();
}
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();
}
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();
}
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);
}
}
Aggregations