Wednesday, November 2, 2011

Re: problems with loading stuff/bootstrapping onModuleLoad triggered by an event

At the moment i read your last post/ understood the problem i knew that you tried it several times - i saw all your vehement efforts to get it into my brain (but some times brains don't want to see :-) ).

i just refactored my code - in fact i haven't changed much (i already had some scheduler stuff in my code). Because all my tasks are done on construction time (gin injected stuff, ApplicationManager registers himself to onTaskDoneEvents in constructor)  i got rid of the public start() method. Now i only have a private start called in the way you suggested it:
...
    @Override
    public void onTopicTreeLoadedEvent(TopicTreeLoadedEvent event) {
        ttReady = true;
        start();
    }
..
    @Override
    public void onAdminUnitsLoaded(AdminUnitsLoadedEvent event) {
        auReady = true;
        start();
    }
...
private void start() {
        if (ttReady && auReady) {
            Scheduler.get().scheduleFinally(new ScheduledCommand() {

                @Override
                public void execute() {
                    // set up activity managers
                    sidePanelAreaManager.setDisplay(contentArea.getWestSideArea());
                    breadCrumbAreaManager.setDisplay(contentArea.getBreadcrumArea());
                    contentMenuAreaManager.setDisplay(contentArea.getContentMenuArea());
                    contentAreaManager.setDisplay(contentArea.getContentArea());
                    // insert dynamic layout in static layout
                    staticView.getContentArea().setWidget(contentArea);
                    contentArea.setDefaultLayout();
                    historyHandler.register(placeController, eventBus, startPlace);
                    historyHandler.handleCurrentHistory();
                    currentPlace = placeController.getWhere();
                }
            });

        }
    }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/u1L5T1n491sJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment