Announcement Announcement Module
Collapse
No announcement yet.
PageCompononentListener Hooks...JIRA issue? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PageCompononentListener Hooks...JIRA issue?

    Hi folks, I just wanted to clarify what Im seeing with people before I think of raising a JIRA issue on this. Only one of my views has a pageComponentListener attached in its getControl() method.


    I launch the app and go to the view with the listener and this series of calls is made on the view simply after a call to showView()

    View OPENED
    View Focus LOST
    View Focus GAINED
    View Focus GAINED

    I then click a toolbar button to show a *different* view and the methods of the original view are still being called in a strange manner as follows...
    showView() different

    View OPENED
    View Focus LOST
    View Focus GAINED
    View Focus GAINED

    .....click to show the original view and I get......

    showView() original

    View Focus LOST
    View Focus GAINED
    View Focus GAINED

    ...different view showView()

    View Focus LOST
    View Focus GAINED
    View Focus GAINED

    So weve certainly got problems here, with the wrong sequence of calls and the listener on the wrong view still being called.

    For my own clarification, my understanding of this lifecycle sequence of events is, that a call to componentOpened() is made each time the view is shown on screen? Or, is that simply called on *creation* of the view.

    Can anyone shed light on correct sequence to these lifecycly calls?

    No matter what, I should probably raise as JIRA issue as this area isnt workingas intended, and id say its a pretty important area?

    Any suggestions?

    Many thanks


    Alan

  • #2
    The PageComponentListener interface defines a PageComponent as a parameter to each method. One thing you should check is if the focus gained and focus lost events are happening for the right components. Your listener should receive a focus lost for one view, and then a focus gained for the new view. It should also receive the appropriate componentOpened and componentClosed events. Beyond that, the event sequences you show do not look correct off hand. It would seem you should be getting "componentClosed" for the old view at some point, and it would seem that you should only get one "componentFocusGained". If I remember correctly, spring-rich currently recreates the view from its ViewDescriptor every time it is opened (or at least every time ApplicationPage.showView(...) is invoked).
    One thing I should note is that PageComponentListener is different than the lifecycle methods built into the PageComponent interface, which the View interface extends. PageComponentListener is for listening in on lifecycle events for all views in the page, while the PageComponent lifecycle methods apply only to the one PageComponent (view). They both share the same method names, except that PageComponentListener also passes in the PageComponent for which the event applies. You mentioned attaching a pageComponentListener in your message, but then speak of the lifecycle methods... so I'm not real sure which technique you are using exactly.

    Comment


    • #3
      thanks for the reply,

      Im working this out on the fly and from some tips in the documentation. I actually found that the second focus message was from a different view later which threw me a bit! I shall experiment further and post my results here, as im sure this information will be useful to others whilst we wait for documentation to be available....heck...perhaps even i could write the documentation for it when im 100% sure ive got it fully understood and working! ;-)

      cheers

      Alan

      Comment


      • #4
        Hi adepue,

        Abstractview does indeed have the samelifecycle methods for view opening/closing and focus management, however, Im not sure I can deduce how these methods are ever called. Overriding has no effect , and I cant see anyother way in whcih Id have to register some form of listener for them etc.

        Has anyone ever seen this functionality working? ie, can anyone show me a simple of example of receiveing the open/close/focus gained/lost calls for a given view?

        I still think theres an issue here an potentially more then one, though perhaps im trying to get code to work that is incomplete in rcp?

        Any ideas people?

        Cheers

        Alan

        Comment


        • #5
          I just did a quick search through my spring-rich code and it appears that componentOpened(), componentFocusGained(), componentFocusLost(), and componentClosed() are never called against a View (or I should say a PageComponent, since View extends PageComponent, and the methods are defined in PageComponent). This must be a feature that was started but has not yet been implemented. I would expect DefaultApplicationPage or AbstractApplicationPage to invoke these methods at the appropriate time. In fact, AbstractApplicationPage has "fire" methods that fire the appropriate events to the PageComponentListeners... would it be appropriate to patch these "fire" methods to also call the PageComponent lifecycle methods? For example:
          Code:
              protected void fireOpened(PageComponent component) {
                  pageComponentListeners.fire("componentOpened", component);
              }
          becomes
          Code:
              protected void fireOpened(PageComponent component) {
                  pageComponentListeners.fire("componentOpened", component);
                  component.componentOpened();
              }
          What do you, spring-rich developers?

          Comment


          • #6
            Looks right to me except in what order should the events notified? I'd notify the component first and then the listeners.

            Peter you've got your name on this class what do you think?

            Ollie

            Comment


            • #7
              I had a look in that code as well, and I dont see where else those calls would go.

              So I think that the two issues are that these PageComponent methods have never been called and the order of the calls being made to the listeners is a bit funky at the moment.

              Eg, for the listeners I never saw a componentClosed() call being made, however Im a bit fuzzy on what exactly Peter's idea of 'closed' is! For instance, all I do is call showView() to have a view fully fill the window - does that mean that the view being replaced has been "closed" and should receive the componentClosed() call?

              Would be nice to hear from the code owner if they were not too busy...

              Cheers

              Alan[/code]

              Comment


              • #8
                At any rate, it's probably worth opening a JIRA issue at this point (or two - one for each problem?).

                - Andy

                Comment


                • #9
                  Raised a JIRA issue RCP-114 - for PageComponent interface methods not being called in Abstract View.......I havent raised a second one over PageComponentListener method order call as im not 100% sure *exactly* what the expected behaviour should be....I need an expert to shed some light on that first ;-)

                  Cheers

                  Alan

                  Comment


                  • #10
                    The lifecycle methods in PageComponent need to be called by the ApplicationPage. Otherwise a PageComponent has to register itself as a PageComponentListener to it's ApplicationPage to get notification (which is pretty lame).

                    I think the best solution would be to adapt the fireXXX methods, as Andy pointed out.

                    This way a PageComponent can simple override and reimplement the lifecycle methods to do extra stuff (such as cleanup/storing and retrieving settings/toolbar contributions/...)

                    For the other problem (the odd sequence of the lifecycle calls), I have a fix lying around. (There are some glitches in the AbstractApplicationPage). I've created a JIRA issue (http://opensource.atlassian.com/proj...browse/RCP-117) to track progress,

                    Peter

                    Comment

                    Working...
                    X