Search in sources :

Example 6 with ValueMap

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());
}
Also used : ValueMap(org.apache.wicket.util.value.ValueMap) Test(org.junit.Test)

Example 7 with ValueMap

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());
}
Also used : ValueMap(org.apache.wicket.util.value.ValueMap) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Example 8 with ValueMap

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");
}
Also used : ValueMap(org.apache.wicket.util.value.ValueMap) Test(org.junit.Test)

Example 9 with ValueMap

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());
}
Also used : ValueMap(org.apache.wicket.util.value.ValueMap) Test(org.junit.Test)

Example 10 with ValueMap

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);
    }
}
Also used : ValueMap(org.apache.wicket.util.value.ValueMap) IValueMap(org.apache.wicket.util.value.IValueMap)

Aggregations

ValueMap (org.apache.wicket.util.value.ValueMap)11 Test (org.junit.Test)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 CheckingObjectOutputStream (org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream)1 ObjectSerializationChecker (org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker)1 ComponentTag (org.apache.wicket.markup.ComponentTag)1 Label (org.apache.wicket.markup.html.basic.Label)1 Border (org.apache.wicket.markup.html.border.Border)1 Panel (org.apache.wicket.markup.html.panel.Panel)1 IModel (org.apache.wicket.model.IModel)1 Model (org.apache.wicket.model.Model)1 PropertyModel (org.apache.wicket.model.PropertyModel)1 IResourceStream (org.apache.wicket.util.resource.IResourceStream)1 ResourceStreamNotFoundException (org.apache.wicket.util.resource.ResourceStreamNotFoundException)1 IValueMap (org.apache.wicket.util.value.IValueMap)1 IModificationWatcher (org.apache.wicket.util.watch.IModificationWatcher)1