Announcement Announcement Module
Collapse
No announcement yet.
Help on 2 forms sharing 1 formModel Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help on 2 forms sharing 1 formModel

    I have a problem when using 2 forms that share the same form model. Basically, form 1 composes of only a few fields. When user has specified the values, the user may proceeds to the next page in the wizard, which is form 2 and it contains much more fields to fill in.

    Some common fields are present on both forms and are editable on both forms. When a validation error occurs on these common fields in either form 1 or form 2, it throws an exception

    Code:
    java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
    	at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1507)
    	at java.awt.Component.getLocationOnScreen(Component.java:1481)
    	at org.springframework.richclient.util.OverlayHelper.positionOverlay(OverlayHelper.java:185)
    	at org.springframework.richclient.util.OverlayHelper.updateOverlay(OverlayHelper.java:165)
    	at org.springframework.richclient.util.OverlayHelper.access$000(OverlayHelper.java:44)
    	at org.springframework.richclient.util.OverlayHelper$2.ancestorMoved(OverlayHelper.java:100)
    	at java.awt.Component.processHierarchyBoundsEvent(Component.java:5299)
    	at java.awt.Component.processEvent(Component.java:4922)
    	at java.awt.Container.processEvent(Container.java:1569)
    	at java.awt.Component.dispatchEventImpl(Component.java:3615)
    It seems it tries to update the UI of the form that is not visible. Am I doing something wrong here? What is the recommended way to do this?

  • #2
    Hi,

    i think it's not possible to use the same form model for 2 forms. I would suggest to use a form model for each form, mabey the form with more fields is subclassing the poorer one?

    _
    Claudio

    Comment


    • #3
      Look at the NewOwnerWizard in the sample application, it has 2 wizardpages, sharing the same Owner instance. You'll need to do something similar to it.

      Hope thi s helps,

      Peter

      Comment


      • #4
        i think it's not possible to use the same form model for 2 forms
        I can't see any reason why multiple forms can't share a single form model... Not that I'm suggesting it works at the moment ;-)

        The exception that hszetu is getting is related to the gymnastics that OverlayHelper is required to go through to place the little error overlay icons. From looking at the code I don't see how this exception can be raised as there is a showing test just before the call to getLocationOnScreen.

        hszetu can you raise this as an issue in Jira and attach a test case as I can't reproduce this.

        Thanks,

        Ollie
        [/code]

        Comment


        • #5
          Smells like bug spirit... . I guess it is just a case not covered by a junit test.

          Oliver did you know the email address of Keth? I should sent him something and it seams he didn't recieved it. I used a somewhat wired email address so I am not sure, that I used the right one.


          Cheers,

          Martin (Kersten)

          PS: That gymnasitc part is nice, I should remember this one. ;-)

          Comment


          • #6
            Thanks for all your responses.

            I have a look at the NewOwnerWizard, it has 2 forms, OwnerGeneralForm & OwnerAddressForm and they share the same form model. But both did not share any common fields. So for curiosity, I tried adding firstName & lastName on the address form as well.

            Guess what, there is no exception. But what happen is that the validation for firstName & lastName only occurs ownerGeneralForm, nothing happens on ownerAddressForm even if you type in something invalid in either firstName or lastName. But if you go back to the general form, the fields are shown as invalid.

            Any idea of this behaviour?

            Comment


            • #7
              You surely found a bug I guess. Raise an issue in the JIRA and let the developers investigate it or even better debug the footprint of the program and compare it. I have to see the code to tell whats going on, but I guess there are some smarter guys out there.

              Try the JIRA and let the developers investigating it for one week. I guess it is not that critical for you now, is it? If it prevents you from shipping the product, just try two forumlar models as a substitute since this issue is solved.

              To help the developers, try to isolate the scenario causing the problem by creating a little demonstration of the bug. As little as better. If you can, I would like to see the demonstration also.


              Cheers,

              Martin (Kersten)

              Comment


              • #8
                I think I know what the problem is. There are actually 2 different issues here.

                The exception I got is ONLY showed up if I put the 2 forms sharing the same form model on common shared JScrollPane and swap the viewport view to show the current form content. If each form has its own scroll pane, everything is fine, no exception.

                Another issue is that petclinic NewOwnerWizard is using the CompoundForm. If I put firstName on the AddressForm as well, there is no validation on the firstName field on the AddressForm. I create my form model directly using SwingFormModel so I didn't see that problem. So somehow, if there are 2 forms created using the same CompoundForm model and there is a common field on both forms, only the first form enforce the validation on that common field.

                Comment


                • #9
                  The exception I got is ONLY showed up if I put the 2 forms sharing the same form model on common shared JScrollPane and swap the viewport view to show the current form content. If each form has its own scroll pane, everything is fine, no exception.
                  Ahh... this makes much more sense now. The OverlayHelper is probably trying to place the overlay on top of original viewport not the new one that you've swapped in. I think there's an expectation in the code that the viewport will never be changed.

                  Ollie

                  Comment

                  Working...
                  X