Package org.springframework.binding.form

Examples of org.springframework.binding.form.FormModel


            }
            return resetTrigger;
        }

        private void registerListeners() {
            FormModel formModel = getFormModel();
            formModel.addCommitListener(this);
            formModel.getFormObjectHolder().addValueChangeListener(this);
        }
View Full Code Here


    }

    public void testInitialValue() {
        TestBean bean = new TestBean();
        bean.setBooleanProperty(true);
        FormModel fm = new DefaultFormModel(bean);
        ToggleButtonBinding binding = new ToggleButtonBinding(new JToggleButton(), fm, "booleanProperty");
        JToggleButton control = (JToggleButton) binding.getControl();
        assertEquals(true, control.isSelected());
    }
View Full Code Here

*/
public class DirtyIndicatorInterceptorFactoryTests extends TestCase {
    public void testGetInterceptor() {
        DirtyIndicatorInterceptorFactory factory = new DirtyIndicatorInterceptorFactory();

        FormModel formModel = new DefaultFormModel();
        DirtyIndicatorInterceptor interceptor = (DirtyIndicatorInterceptor)factory.getInterceptor(formModel);

        assertNotNull("factory returned null", interceptor);
    }
View Full Code Here

*/
public class SearchGoogleCommand extends ApplicationWindowAwareCommand {
 
   protected void doExecuteCommand() {
    SearchBean searchBean = new SearchBean();
      FormModel formModel = FormModelHelper.createFormModel(searchBean);
      final SearchForm form = new SearchForm(formModel);
      FormBackedDialogPage page = new FormBackedDialogPage(form);

      TitledPageApplicationDialog dialog =
          new TitledPageApplicationDialog(page, getParentWindowControl()) {
View Full Code Here

      return;
    }
        TestBean bean = new TestBean();
        bean.setProperty("original value");

        FormModel formModel = new DefaultFormModel(bean);

        DirtyIndicatorInterceptor interceptor = new DirtyIndicatorInterceptor(formModel);
        assertEquals(formModel, interceptor.getFormModel());

        Binding binding = new SwingBindingFactory(formModel).createBinding("property");
        JTextField field = (JTextField)binding.getControl();
        field.setColumns(25);
        assertNotNull("sanity check: binding defines no component", field);

        interceptor.processComponent("property", field);

        // start a frame to trigger visual updates
        JFrame frame = new JFrame("test");
        frame.getContentPane().add(field);
        frame.pack();
        frame.setVisible(true);

        // trigger a show of the overlay, so we can get a reference to it
        ValueModel valueModel = formModel.getValueModel("property");
        valueModel.setValue("dirty");

        // sleep for a while so the gui can update itself
        Thread.sleep(500);
        formModel.revert();

        // find a reference to the overlay component
        JLayeredPane layeredPane = frame.getRootPane().getLayeredPane();
        assertEquals("sanity check: assume the layered pane only has one component, and that it is a panel and the overlay",
                     2, layeredPane.getComponentCount());
View Full Code Here

        assertTrue(fm.isValidating());
        assertEquals(2, pcl.eventCount());
    }

    public void testReadOnlyRevert() {
        FormModel fm = getFormModel(new TestBean());
        fm.getValueModel("readOnly");
        fm.revert();

        // no additional asserts, this test should just not throw an exception!
    }
View Full Code Here

        assertTrue(um == null || um.size() == 0);
    }
   
    public void testInFormModel() {
        final AnnotationAwareBeanPropertyAccessStrategy pas = new AnnotationAwareBeanPropertyAccessStrategy(new TestBean());
        final FormModel fm = new DefaultFormModel(pas);
       
        FieldMetadata pm = fm.getFieldMetadata("name");
        assertNotNull(pm);
        assertEquals(Boolean.TRUE, pm.getUserMetadata("org.springframework.binding.support.NoValueAnnotation"));
        NoValueAnnotation nva = (NoValueAnnotation)pm.getUserMetadata("@" + NoValueAnnotation.class.getName());
        assertNotNull(nva);
        assertEquals(2, pm.getAllUserMetadata().size());
       
        pm = fm.getFieldMetadata("age");
        assertNotNull(pm);
        assertEquals(Boolean.TRUE, pm.getUserMetadata("org.springframework.binding.support.NoValueAnnotation"));
        assertEquals("The Age Method", pm.getUserMetadata("org.springframework.binding.support.SingleValueAnnotation"));
        nva = (NoValueAnnotation)pm.getUserMetadata("@" + NoValueAnnotation.class.getName());
        assertNotNull(nva);
        SingleValueAnnotation sva = (SingleValueAnnotation)pm.getUserMetadata("@" + SingleValueAnnotation.class.getName());
        assertNotNull(sva);
        assertEquals("The Age Method", sva.value());
        assertEquals(4, pm.getAllUserMetadata().size());
       
        pm = fm.getFieldMetadata("rank");
        assertNotNull(pm);
        assertEquals(Boolean.TRUE, pm.getUserMetadata("org.springframework.binding.support.NoValueAnnotation"));
        assertEquals("The Rank Method", pm.getUserMetadata("org.springframework.binding.support.SingleValueAnnotation"));
        assertEquals(Boolean.TRUE, pm.getUserMetadata("org.springframework.binding.support.MultiValueAnnotation"));
        assertEquals("First Test Name", pm.getUserMetadata("org.springframework.binding.support.MultiValueAnnotation.name"));
        assertEquals(24.5, pm.getUserMetadata("org.springframework.binding.support.MultiValueAnnotation.age"));
        assertEquals(10, pm.getUserMetadata("org.springframework.binding.support.MultiValueAnnotation.rank"));
        nva = (NoValueAnnotation)pm.getUserMetadata("@" + NoValueAnnotation.class.getName());
        assertNotNull(nva);
        sva = (SingleValueAnnotation)pm.getUserMetadata("@" + SingleValueAnnotation.class.getName());
        assertNotNull(sva);
        assertEquals("The Rank Method", sva.value());
        MultiValueAnnotation mva = (MultiValueAnnotation)pm.getUserMetadata("@" + MultiValueAnnotation.class.getName());
        assertNotNull(mva);
        assertEquals("First Test Name", mva.name());
        assertEquals(24.5, mva.age());
        assertEquals(10, mva.rank());
        assertEquals(9, pm.getAllUserMetadata().size());
       
        pm = fm.getFieldMetadata("description");
        assertNotNull(pm);
        assertTrue(pm.getAllUserMetadata() == null || pm.getAllUserMetadata().size() == 0);
    }
View Full Code Here

    }
  }

  public boolean isCommittable() {
    for (Iterator i = children.iterator(); i.hasNext();) {
      final FormModel childFormModel = (FormModel) i.next();
      if (!childFormModel.isCommittable()) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

        else {
          dirtyValueAndFormModels.remove(metadata);
        }
      }
      else if (source instanceof FormModel) {
        FormModel formModel = (FormModel) source;
        if (formModel.isDirty()) {
          dirtyValueAndFormModels.add(formModel);
        }
        else {
          dirtyValueAndFormModels.remove(formModel);
        }
View Full Code Here

   * not be dirty.
   * </p>
   */
  public void testBufferedFormModelSetFormObjectNotDirty() {
    String someString = "someString";
    FormModel model = getFormModel(new TestBean());
    ValueModel valueModel = model.getValueModel("simpleProperty");

    assertEquals("Initial check, formmodel not dirty.", false, model.isDirty());

    valueModel.setValue(someString);
    assertEquals("Value changed, model should be dirty.", true, model.isDirty());

    TestBean newFormObject = new TestBean();
    newFormObject.setSimpleProperty(someString);
    model.setFormObject(newFormObject);
    assertEquals("New formObject is set, model should not be dirty.", false, model.isDirty());
  }
View Full Code Here

TOP

Related Classes of org.springframework.binding.form.FormModel

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.