I keep getting the error: "Method must be called before the component
is rendered"


I created a presenter ResultsPresenter which gets lazy loaded when the
user clicks the "Results" button.  The result button call back calls
the eventBus.viewResults event, which calls the onViewResults in the
results presenter, which triggers the RootPanelPresenter to add the
view to the RootPanel.

However, when the RootPresenter tries to add the results widget to the
rootpanel, it gets an error saying "Method must be called before the
component is rendered".

I suspect this is due to the fact that I am using GXT because GXT
panels are not rendered until they are added to the root panel, but I
don't know any other way around it.


@Presenter( view = ResultsView.class )
public class ResultsPresenter extends
LazyPresenter<ResultsPresenter.IResultsView, GridEditorUIEventBus> {

        public void onViewResults() {
                eventBus.addViewResults( view.getViewWidget() );
        }
}


IMPORTANT NOTE: everything works perfectly if I add the results widget
to the root panel in the onStart method, and set it to invisible, and
then set it visible when I need it.  However, I feel like I shouldn't
need to do this because I would prefer to not render everything at
startup, and it's also a pain to have the extra code of storing
everything in a datastructure in rootpanelpresenter.

i.e.  THIS WORKS:
        public void onViewResults() {
                eventBus.showViewResults( );  // set widget to visible
        }

        public void onStart(){
                eventBus.renderViewResults( view.getViewWidget() ); // add 
widget to
root panel, but set invisible
        }

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

Reply via email to