Results 1 to 6 of 6

Thread: Possible Bug in new Rules

  1. #1
    Join Date
    Aug 2004
    Location
    Northridge, CA
    Posts
    151

    Default Possible Bug in new Rules

    I have a rule define as following,

    Code:
        private Rules createGlobalUserRules() {
            return new Rules(GlobalUser.class) {
                protected void initRules() {
                    add("firstName", getNameValueConstraint());
                    add("lastName", getNameValueConstraint());
                    add(not(eqProperty("firstName", "lastName")));
                }
            };
        }
    and then I have a GlobalUserForm which is an editor for GlobalUser domain object. But when I set a GlobalUser on editor by
    Code:
    globalUserEditorModel.setFormObject(selectedObject);
    Event though the selected user has first name and last name which are not equal and have valid values, form still show error on these two fields and Apply button is not enabled. Now if i just add a space and then delete it or just delete the last character in firstName and type it again then everything is fine. Seems like my form is not getting validated correctly on setFormObject().

    Amad

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Thanks Amad, good report. Will take a look at this promptly.
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Amad,

    I am unable to recreate this issue quickly in petclinic...

    Are you using the form in conjuction with a FormBackedDialogPage or FormBackedWizardPage? I had to put a temp workaround in those classes becaues validation during form model construction is now an manual process. This is because, for validation to work with properties that affect other properties, all properties must currently be present on the model first.

    Try calling ValidatingFormModel.validate() manually after form model construction and see if that fixes the problem. After construction, setFormObject() should trigger a revalidate -- which it appears to be doing, Petclinic is working nicely. Take a look at FormBackedDialogPage's createControl method to see how i does it --

    Above is a bandaid solution until I get a chance to do some refactoring--form models should really add property value models automatically, when needed, instead of manually. Expect tests to prove this is or is not working soon. :-)
    Keith Donald
    Core Spring Development Team

  4. #4
    Join Date
    Aug 2004
    Location
    Northridge, CA
    Posts
    151

    Default

    Keith,

    I am using a CompoundForm in TabbedDialogPage (I don't have the code here so I don't remember the correct class name). I will try to call validate() manually as well.

    Thanks

    Amad

  5. #5
    Join Date
    Aug 2004
    Location
    Northridge, CA
    Posts
    151

    Default

    As I mentioned i am using CompundFormModel in a TabbedDialogPage. I add forms to tabbedDialogPage and I set the FormObject on my compoundFormModel. As there is no way from TabbedDialogPage to validate all the forms it contains, I have added a FormObjectChangeListener and I call validate everytime there is valueChanged() called. It has fixed my problem but assuming that this is a quick work-around?

    Amad

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Yes, this won't be required in the future.
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  2. Replies: 1
    Last Post: Jul 18th, 2005, 12:43 PM
  3. Default Rules
    By Boris in forum Swing
    Replies: 1
    Last Post: Dec 13th, 2004, 06:29 AM
  4. Rules
    By vpeurala in forum Swing
    Replies: 4
    Last Post: Nov 26th, 2004, 06:22 PM
  5. Rules Source
    By ulil in forum Swing
    Replies: 1
    Last Post: Oct 8th, 2004, 09:09 AM

Posting Permissions

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