Announcement Announcement Module
No announcement yet.
Binding error messages Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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):
    	final PersonChildForm form = new PersonChildForm();
    	// After executing new form object command validation messages are empty
    	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
    	Assert.assertEquals(0, form.getFormModel().getValidationResults().getMessageCount());
    	// After executing new form object command the count backs to 1!!
    	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


    • #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())
        -->(1) DefaultFormModel$ValidatingFormValueModel <<== bindingErrorMessages
           +-->(2) TypeConverter
               +-->(3) ValidatingFormValueModel          <<== formModel.getValueModel(propertyPath);
                   +-->(4) FormModelMediatingValueModel
                       +-->(5) BufferedValueModel  +--->ValueHolder
                      wraps|                       |parent    
      Last edited by julio.arguello; Oct 1st, 2009, 03:56 PM. Reason: Better explanation