Package org.springframework.binding.value.support

Examples of org.springframework.binding.value.support.ValueHolder


   * provide access to the properties of the provided object.
   *
   * @param object the object to be accessed through this class.
   */
  public AbstractPropertyAccessStrategy(Object object) {
    this(new ValueHolder(object));
  }
View Full Code Here


        // XXX: fails
//        testTwoFormModelsInHierarchyShareSameFormObjectHolder(false);
    }
   
    public void testTwoFormModelsInHierarchyShareSameFormObjectHolder(boolean buffered) {
        ValueHolder vm = new ValueHolder(new TestBean());
        AbstractFormModel fm1 = getFormModel(vm, buffered);
        AbstractFormModel fm2 = getFormModel(vm, buffered);
        TestPropertyChangeListener pcl = new TestPropertyChangeListener(ValueModel.VALUE_PROPERTY);
        fm2.getValueModel("simpleProperty").addValueChangeListener(pcl);
        fm1.addChild(fm2);
View Full Code Here

    private TestDataListener testListener;

    protected String setUpBinding() {
        cbb = new ComboBoxBinding(fm, "simpleProperty");
        cb = (JComboBox) cbb.getControl();
        sih = new ValueHolder(SELECTABLEITEMS);
        cbb.setSelectableItems(sih);
        testListener = new TestDataListener();
        cb.getModel().addListDataListener(testListener);
        return "simpleProperty";
    }
View Full Code Here

    }

    public void testSelectableItemHolderNullValue() {
        ComboBoxBinding binding = new ComboBoxBinding(fm, "simpleProperty");
        binding.getControl();
        ValueHolder valueHolder = new ValueHolder();
        try {
            binding.setSelectableItems(valueHolder);
            fail();
        } catch (IllegalArgumentException e) {
            // expected
View Full Code Here

        assertEquals(1, b.getContext().size(), 1);
        assertEquals(items, b.getContext().get(ComboBoxBinder.SELECTABLE_ITEMS_KEY));
    }

    public void testCreateBoundComboBoxStringValueModel() {
        ValueModel valueHolder = new ValueHolder();
        TestableBinding b = (TestableBinding)sbf.createBoundComboBox("name", valueHolder);
        assertBindingProperties(b, JComboBox.class, null, "name");
        assertEquals(1, b.getContext().size(), 1);
        assertEquals(valueHolder, b.getContext().get(ComboBoxBinder.SELECTABLE_ITEMS_KEY));
    }
View Full Code Here

            // expected
        }
    }

    public void testCreateBoundComboBoxStringValueModelString() {
        ValueModel selectableItemsHolder = new ValueHolder(new Object());
        TestableBinding b = (TestableBinding)sbf.createBoundComboBox("name", selectableItemsHolder, "displayProperty");
        assertBindingProperties(b, JComboBox.class, null, "name");
        assertEquals(4, b.getContext().size());
        assertEquals(selectableItemsHolder, b.getContext().get(ComboBoxBinder.SELECTABLE_ITEMS_KEY));
        assertEquals("displayProperty",
View Full Code Here

        assertEquals("displayProperty", getComparatorProperty(b));
        assertFalse(b.getContext().containsKey(ListBinder.SELECTION_MODE_KEY));
    }

    public void testCreateBoundListStringValueModelString() {
        ValueModel selectableItemsHolder = new ValueHolder(new Object());
        TestableBinding b = (TestableBinding)sbf.createBoundList("listProperty", selectableItemsHolder,
                "displayProperty");
        assertBindingProperties(b, JList.class, null, "listProperty");

        assertEquals(3, b.getContext().size());
View Full Code Here

*/
public class ValueModel2EventListBridgeTests extends TestCase {
    public void testValueHolderMustContainCollection() {
        EventList eventList = new BasicEventList();

        ValueModel valueModel = new ValueHolder("test");

        try {
            new ValueModel2EventListBridge(valueModel, eventList);
            fail("Must throw exception");
        }
View Full Code Here

    public void testAutomaticSynchronization() {
        List list1 = Arrays.asList(new String[] { "item 1", "item2", "item3" });
        List list2 = Arrays.asList(new String[] { "item 4", "item5", "item6" });

        EventList eventList = new BasicEventList();
        ValueModel valueModel = new ValueHolder(list1);

        ValueModel2EventListBridge bridge = new ValueModel2EventListBridge(valueModel, eventList);
        assertEquals("auto sync: data copied in constructor", list1, eventList);

        valueModel.setValue(list2);
        assertEquals("when value in ValueModel changes, it's copied to the EventList", list2, eventList);
    }
View Full Code Here

    public void testManualSynchronization() {
        List list1 = Arrays.asList(new String[] { "item 1", "item2", "item3" });
        List list2 = Arrays.asList(new String[] { "item 4", "item5", "item6" });

        EventList eventList = new BasicEventList();
        ValueModel valueModel = new ValueHolder(list1);

        ValueModel2EventListBridge bridge = new ValueModel2EventListBridge(valueModel, eventList, true);
        assertTrue("manual sync: data not copied in constructor", eventList.isEmpty());

        bridge.synchronize();
        assertEquals("sync copies data", list1, eventList);

        valueModel.setValue(list2);
        assertEquals("when value in ValueModel changes, it's NOT copied to the EventList", list1, eventList);

        bridge.synchronize();
        assertEquals(list2, eventList);
    }
View Full Code Here

TOP

Related Classes of org.springframework.binding.value.support.ValueHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.