Package org.springframework.binding.value

Examples of org.springframework.binding.value.ValueModel


  public void testUnbufferedWritesThrough() {
    TestBean p = new TestBean();
    BeanPropertyAccessStrategy pas = new BeanPropertyAccessStrategy(p);
    AbstractFormModel fm = getFormModel(pas, false);
    ValueModel vm = fm.getValueModel("simpleProperty");

    vm.setValue("1");
    assertEquals("1", p.getSimpleProperty());

    vm.setValue(null);
    assertEquals(null, p.getSimpleProperty());
  }
View Full Code Here


  public void testBufferedDoesNotWriteThrough() {
    TestBean p = new TestBean();
    BeanPropertyAccessStrategy pas = new BeanPropertyAccessStrategy(p);
    AbstractFormModel fm = getFormModel(pas, true);
    ValueModel vm = fm.getValueModel("simpleProperty");

    vm.setValue("1");
    assertEquals(null, p.getSimpleProperty());

    vm.setValue(null);
    assertEquals(null, p.getSimpleProperty());
  }
View Full Code Here

    TestBean p = new TestBean();
    BeanPropertyAccessStrategy pas = new BeanPropertyAccessStrategy(p);
    TestPropertyChangeListener pcl = new TestPropertyChangeListener(FormModel.DIRTY_PROPERTY);
    AbstractFormModel fm = getFormModel(pas, buffering);
    fm.addPropertyChangeListener(FormModel.DIRTY_PROPERTY, pcl);
    ValueModel vm = fm.getValueModel("simpleProperty");
    assertTrue(!fm.isDirty());

    vm.setValue("2");
    assertTrue(fm.isDirty());
    assertEquals(1, pcl.eventCount());

    fm.commit();
    assertTrue(!fm.isDirty());
    assertEquals(2, pcl.eventCount());

    vm.setValue("1");
    assertTrue(fm.isDirty());
    assertEquals(3, pcl.eventCount());

    fm.setFormObject(new TestBean());
    assertTrue(!fm.isDirty());
    assertEquals(4, pcl.eventCount());

    vm.setValue("2");
    assertTrue(fm.isDirty());
    assertEquals(5, pcl.eventCount());

    fm.revert();
    assertTrue(!fm.isDirty());
View Full Code Here

     *
     * @return The child form model
     */
    public static ValidatingFormModel createChildPageFormModel(HierarchicalFormModel parentModel, String childPageName,
                                                               String childFormObjectPropertyPath) {
        final ValueModel childValueModel = parentModel.getValueModel(childFormObjectPropertyPath);
        return createChildPageFormModel(parentModel, childPageName, childValueModel);
    }
View Full Code Here

  private class ValueModelCache extends CachingMapDecorator {

    protected Object create(Object propertyPath) {
      String fullPropertyPath = getFullPropertyPath((String) propertyPath);
      String parentPropertyPath = getParentPropertyPath(fullPropertyPath);
      ValueModel parentValueModel = parentPropertyPath == "" ? domainObjectHolder : (ValueModel) valueModelCache
          .get(parentPropertyPath);
      return new PropertyValueModel(parentValueModel, fullPropertyPath);
    }
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

                ((BeanPropertyEditorClosure)b.getContext().get(ComboBoxBinder.EDITOR_KEY)).getRenderedProperty());
        assertEquals("displayProperty", getComparatorProperty(b));
    }

    public void testCreateBoundListModel() {
        ValueModel vm = ((DefaultFormModel)sbf.getFormModel()).getFormObjectPropertyAccessStrategy().getPropertyValueModel(
                "listProperty");
        ObservableList observableList = sbf.createBoundListModel("listProperty");

        ArrayList list = new ArrayList();
        list.add(new Integer(1));
        vm.setValue(list);
        assertEquals(new Integer(1), observableList.get(0));
        observableList.add(new Integer(2));
        assertEquals(1, ((List)vm.getValue()).size());
        sbf.getFormModel().commit();
        assertEquals(new Integer(2), ((List)vm.getValue()).get(1));
    }
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

TOP

Related Classes of org.springframework.binding.value.ValueModel

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.