use of org.apache.wicket.util.value.ValueMap in project wicket by apache.
the class InheritedModelTest method testResetInheritedModelFlag.
/**
* Tests if Component#FLAG_INHERITABLE_MODEL reset after model change (WICKET-3413).
*/
@Test
public void testResetInheritedModelFlag() {
ValueMap data1 = new ValueMap();
data1.put("label", "foo");
ValueMap data2 = new ValueMap();
data2.put("value", "bar");
InheritedTestPage page = new InheritedTestPage();
page.setDefaultModel(new CompoundPropertyModel<>(data1));
tester.startPage(page);
assertEquals("foo", page.label.getDefaultModelObject());
page.label.setDefaultModel(new PropertyModel<String>(data2, "value"));
tester.startPage(page);
assertEquals("bar", page.label.getDefaultModelObject());
page.detach();
tester.startPage(page);
assertEquals("bar", page.label.getDefaultModelObject());
}
use of org.apache.wicket.util.value.ValueMap in project wicket by apache.
the class InheritedModelTest method testCompoundPropertyModelDirect.
/**
* Tests the CPM by setting a different root model using a direct scenario.
*/
@Test
public void testCompoundPropertyModelDirect() {
ValueMap data1 = new ValueMap();
data1.put("label", "foo");
ValueMap data2 = new ValueMap();
data2.put("label", "bar");
WebMarkupContainer parent = new WebMarkupContainer("foo");
Label label = new Label("label");
parent.add(label);
parent.setDefaultModel(new CompoundPropertyModel<>(data1));
assertEquals("foo", label.getDefaultModelObject());
parent.setDefaultModel(new CompoundPropertyModel<>(data2));
assertEquals("bar", label.getDefaultModelObject());
data2.put("label", "foo");
assertEquals("foo", label.getDefaultModelObject());
}
use of org.apache.wicket.util.value.ValueMap in project wicket by apache.
the class InheritedModelTest method testCompoundPropertyModelRendered.
/**
* Tests the CPM inheritance by setting a different root model using a rendered scenario.
*/
@Test
public void testCompoundPropertyModelRendered() {
ValueMap data1 = new ValueMap();
data1.put("label", "foo");
ValueMap data2 = new ValueMap();
data2.put("label", "bar");
InheritedTestPage page = new InheritedTestPage();
page.setDefaultModel(new CompoundPropertyModel<>(data1));
tester.startPage(page);
tester.assertLabel("label", "foo");
page.setDefaultModel(new CompoundPropertyModel<>(data2));
tester.startPage(page);
tester.assertLabel("label", "bar");
}
use of org.apache.wicket.util.value.ValueMap in project wicket by apache.
the class InheritedModelTest method testResetInheritedModelFlag2.
/**
* Tests if Component#FLAG_INHERITABLE_MODEL reset after model change (WICKET-5655).
*/
@Test
public void testResetInheritedModelFlag2() {
ValueMap data1 = new ValueMap();
data1.put("label", "foo");
ValueMap data2 = new ValueMap();
data2.put("value", "bar");
InheritedTestPage page = new InheritedTestPage();
page.setDefaultModel(new CompoundPropertyModel<>(data1));
tester.startPage(page);
assertEquals("foo", page.label.getDefaultModelObject());
page.label.setDefaultModel(new CompoundPropertyModel<String>(new PropertyModel<String>(data2, "value")));
tester.startPage(page);
assertEquals("bar", page.label.getDefaultModelObject());
page.detach();
tester.startPage(page);
assertEquals("bar", page.label.getDefaultModelObject());
}
use of org.apache.wicket.util.value.ValueMap in project wicket by apache.
the class XmlTag method copyPropertiesTo.
/**
* Copies all internal properties from this tag to <code>dest</code>. This is basically cloning
* without instance creation.
*
* @param dest
* tag whose properties will be set
*/
void copyPropertiesTo(final XmlTag dest) {
dest.namespace = namespace;
dest.name = name;
dest.text = text;
dest.type = type;
dest.isMutable = true;
dest.closes = closes;
dest.copyOf = copyOf;
if (attributes != null) {
dest.attributes = new ValueMap(attributes);
}
}
Aggregations