Announcement Announcement Module
Collapse
No announcement yet.
DefaultFormModel have a bad bug Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultFormModel have a bad bug

    Code:
            public void testDefaultFormModel() {
        		User user = new User();
                DefaultFormModel formModel = new DefaultFormModel(user);
                ValueModel nameModel1 = formModel.add("name");
                ValueModel nameModel2 = formModel.getValueModel("name");
                assertEquals(nameModel1,nameModel2);
        }
    because this test can't pass, the second test can't succeed.

    Code:
        public void testValidatingFormModel() {
        		User user = new User();
                ValidatingFormModel formModel = new ValidatingFormModel(user);
                DefaultRulesSource ruleSource = new DefaultRulesSource();
                Rules validationRules = new Rules(User.class) {
                         protected void initRules() {
                             add("name", all(new Constraint[] {required(),
                                     minLength(4)}));
                         }
                 };
                ruleSource.addRules(validationRules);
                formModel.setRulesSource(ruleSource);
                ValueModel nameModel = formModel.add("name");
                JTextField j1 = new JTextField();
                new AsYouTypeTextComponentAdapter(j1,nameModel);
                 j1.setText("liuwei");
                formModel.commit();
    
                assertEquals(user.getName(),"liuwei");
        }

  • #2
    You have to create form model with like :

    FomModelHelper.createFormModel ...

    regards

    Comment

    Working...
    X