Announcement Announcement Module
Collapse
No announcement yet.
Binding error messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding error messages

    Hi all,

    I have been using Spring RCP for 3 years, but I have just realized a rare behaviour:

    "Binding error messages are not clear after reseting a form"

    The reason is that the unique class responsible for clearing "bindingErrorMessages" property (ValidatingFormValueModel) is not aware of form object changed action (however BufferedValueModel throw its commit trigger is aware).

    Do you have any idea? Perhaps DefaultFormModel#setFormObject should clear binding errores messages.

    This simple test demonstrates this failure (PersonChildForm is a very simple form with an "age" number property):
    Code:
    	final PersonChildForm form = new PersonChildForm();
    
    	// After executing new form object command validation messages are empty
    	form.getNewFormObjectCommand().execute();
    	Assert.assertEquals(0, form.getFormModel().getValidationResults().getMessageCount());
    
    	// Set a illegal age and a validation error is raised
    	form.getAgeControl().setText("Illegal Value");
    	Assert.assertEquals(1, form.getFormModel().getValidationResults().getMessageCount());
    
    	// Execute the reset command and the count backs to 0
    	form.reset();
    	Assert.assertEquals(0, form.getFormModel().getValidationResults().getMessageCount());
    
    	// After executing new form object command the count backs to 1!!
    	form.getNewFormObjectCommand().execute();
    	Assert.assertEquals(0, form.getFormModel().getValidationResults().getMessageCount());
    Thank you very much!
    Last edited by julio.arguello; Oct 2nd, 2009, 03:38 PM. Reason: Clarifying

  • #2
    Jan and me are diving in

    Comment


    • #3
      Some hint

      Thank you very much!!

      This figure tries to represent the typical value models wrapping structure:
      • The value model capable of being stored into the "bindingErrorMessages" map is the first one, the non wrapped value model, of type ValidatingFormValueModel
      • However, whenever a new form object is set, the value model aware of the change is the 5th, of type BufferedValueModel.

      Note that the unique way of clearing binding errors is setting a right value in the 1st value model. Listening for wrapped value model change events is not a solution because after reseting, the 5th value model doesn't compulsory change its value.

      I think the easiest solution is to clear the map just before setting a new form object (DefaultFormModel#setFormObject())
      Code:
        -->(1) DefaultFormModel$ValidatingFormValueModel <<== bindingErrorMessages
      wraps|
           +-->(2) TypeConverter
          wraps|
               +-->(3) ValidatingFormValueModel          <<== formModel.getValueModel(propertyPath);
              wraps|      
                   +-->(4) FormModelMediatingValueModel
                  wraps|
                       +-->(5) BufferedValueModel  +--->ValueHolder
                      wraps|                       |parent    
                           +-->PropertyValueModel--+
      Last edited by julio.arguello; Oct 1st, 2009, 03:56 PM. Reason: Better explanation

      Comment

      Working...
      X