use of org.apache.tapestry5.services.PersistentFieldStrategy in project tapestry-5 by apache.
the class PersistentFieldManagerImpl method postChange.
public void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue) {
String strategyName = findStrategy(resources, fieldName);
PersistentFieldStrategy strategy = getStrategy(strategyName);
strategy.postChange(pageName, resources.getNestedId(), fieldName, newValue);
}
use of org.apache.tapestry5.services.PersistentFieldStrategy in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method post_change_strategy_by_meta_data.
@Test
public void post_change_strategy_by_meta_data() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
String strategyName = "foo";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
MetaDataLocator locator = mockMetaDataLocator();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put(strategyName, strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, "");
train_findMeta(locator, SymbolConstants.PERSISTENCE_STRATEGY, resources, String.class, strategyName);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(locator, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
use of org.apache.tapestry5.services.PersistentFieldStrategy in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method post_change_with_ultimate_default_strategy.
@Test
public void post_change_with_ultimate_default_strategy() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
MetaDataLocator locator = mockMetaDataLocator();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put(PersistenceConstants.SESSION, strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, "");
train_findMeta(locator, SymbolConstants.PERSISTENCE_STRATEGY, resources, String.class, PersistenceConstants.SESSION);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(locator, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
use of org.apache.tapestry5.services.PersistentFieldStrategy in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method post_change.
@Test
public void post_change() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
String strategyName = "foo";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put(strategyName, strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, strategyName);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(null, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
use of org.apache.tapestry5.services.PersistentFieldStrategy in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method strategy_name_is_case_insensitive.
public void strategy_name_is_case_insensitive() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
String strategyName = "FOO";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put("foo", strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, strategyName);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(null, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
Aggregations