Results 1 to 5 of 5

Thread: recent changes affeting addChildForm?

  1. #1
    Join Date
    Aug 2005
    Location
    London (the English one!)
    Posts
    378

    Default recent changes affeting addChildForm?

    Hi

    I believe that a recent change (say over the last 1 or 2 month) has a negative effect on the method addChildForm on AbstractForm.

    I am using that method, as suggested by Larry a while back, to embed a Master/Detail component in an existing form.

    e.g.
    Code:
        public static class CapturePreferenceForm extends AbstractForm {
    
            public CapturePreferenceForm(final FormModel formModel) {
                super(formModel, "capturePreferenceForm");
            }
    
            protected JComponent createFormControl() {
                TableFormBuilder formBuilder = new TableFormBuilder(getBindingFactory());
                formBuilder.add("bla");
                formBuilder.row();
    
                Form masterForm = new MyForm(getFormModel(), "myDefaults",
                        MyDefault.class);
                formBuilder.getLayoutBuilder().cell(masterForm.getControl());
    
                addChildForm(masterForm);
    
                return formBuilder.getForm();
            }
        }
    Now the addChildForm fails on assertion failure "already has a parent"...
    Code:
    java.lang.IllegalArgumentException: Child form model '[DefaultFormModel@45f4ae id = 'XXX', buffered = true, enabled = true, dirty = false, validating = true, validationResults = [DefaultValidationResultsModel@c2ccac messages = set[[empty]]]]' already has a parent
            at org.springframework.util.Assert.isTrue(Assert.java:65)
            at org.springframework.binding.form.support.AbstractFormModel.addChild(AbstractFormModel.java:239)
            at org.springframework.richclient.form.AbstractForm.addChildForm(AbstractForm.java:192)
    Could somebody confirm what has changed and how I should call this method?

    Looks like the model may have changed?

    Thanks

    Benoit

  2. #2
    Join Date
    Apr 2006
    Location
    Germany, Berlin
    Posts
    61

    Default

    take a look at http://opensource.atlassian.com/proj...browse/RCP-386.
    There is currently no solution but we have to fix this before a release.
    ___
    Mathias

  3. #3
    Join Date
    Aug 2005
    Location
    London (the English one!)
    Posts
    378

    Default

    Hi Matthias,

    Yes, it is my issue. I believe that the Master/Details form builds the child model via that constructor... Bit of a bummer... what has changed? 5 of my screens are now broken due to that...

    B.

  4. #4
    Join Date
    Aug 2005
    Location
    London (the English one!)
    Posts
    378

    Default

    May be it is a bit cheeky... but if I add || child.getParent()==this in the AbstractFormModel, it seems to work:

    Code:
            Assert.isTrue(child.getParent() == null || child.getParent()==this, "Child form model '" + child + "' already has a parent and it is not this model");
    I'm trying to say it is ok to add a child form if the child model does not have a parent or if the parent is already "this" model....

    Not sure how valid that is...
    Benoit

  5. #5
    Join Date
    Apr 2006
    Location
    Germany, Berlin
    Posts
    61

    Default

    Ok I fixed that now. If the form models parent is already this it will do just nothing. I think it is safe to expect that the listeners where already registered on the form model.
    ___
    Mathias

Posting Permissions

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