Announcement Announcement Module
Collapse
No announcement yet.
recent changes affeting addChildForm? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment

          Working...
          X