Results 1 to 3 of 3

Thread: Binding error messages

  1. #1

    Default 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 at 03:38 PM. Reason: Clarifying

  2. #2
    Join Date
    Mar 2007
    Location
    Oudenaarde
    Posts
    294

    Default

    Jan and me are diving in
    MSN: PM me please
    Skype: doclo_lieven

    Spring Rich Client Project Lead

  3. #3

    Default 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 at 03:56 PM. Reason: Better explanation

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •