Monday, December 26, 2011

widget's parent does not implement HasWidgets

hi,

i m having trouble with my GWT web app. i use the gwt-presenter
module and try to follow it, but it failed at entryPoint file at the
line

RootPanel.get().add(appPresenter.getDisplay().asWidget());

throw the message as:
java.lang.IllegalStateException: This widget's parent does not
implement HasWidgets
at
com.google.gwt.user.client.ui.Widget.removeFromParent(Widget.java:204)
at
com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:88)
at
com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:97)
at
com.medio.client.dashboardcon.console.client.MyWeb.onModuleLoad(MyWeb.java:
61)

I really cannot figure out why, the codes are simple enough,here are
the codes:

MyWeb.java
public class MyWeb implements EntryPoint {
private final MyGinjector _injector =
GWT.create(MyGinjector.class);
@Override
public void onModuleLoad() {
final AppPresenter appPresenter =
_injector.getAppPresenter();
final EventBus eventBus = _injector.getEventBus();
final PlaceManager placeManager =
_injector.getPlaceManager();

RootPanel.get().add(appPresenter.getDisplay().asWidget());
placeManager.fireCurrentPlace();
}
}

MyGinjector.java
public interface MyGinjector extends Ginjector {
PlaceManager getPlaceManager();
EventBus getEventBus();
AppPresenter getAppPresenter();
}

MyModule.java
public class MyModule extends AbstractPresenterModule {
@Override
protected void configure() {

bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
bind(PlaceManager.class).in(Singleton.class);
bindPresenter(AppPresenter.class, AppPresenter.Display.class,
AppView.class);
...
}

AppPresenter.java
public class AppPresenter extends
WidgetPresenter<AppPresenter.Display> {

public interface Display extends WidgetDisplay {
void addContent(WidgetDisplay display);
void removeContent();
void addHeader(WidgetDisplay display);
}

private final Provider<HeaderPresenter> _headerPresenter;
private final Provider<HomePresenter> _homePresenter;

@Inject
public AppPresenter(Display display, EventBus eventBus,
Provider<HeaderPresenter> headerPresenter,
Provider<HomePresenter> HomePresenter) {
super(display, eventBus);

this._headerPresenter = headerPresenter;
this. _homePresenter = HomePresenter;


display.addHeader(this._headerPresenter.get().getDisplay());
display.addContent(this. _homePresenter().getDisplay());
}
...
}

AppView.java
public class AppView extends Composite implements
AppPresenter.Display {
private final DockPanel panel;
private Widget content;

public AppView() {
panel = new DockPanel();
panel.setStyleName("main");
initWidget(panel);
}

@Override
public void addContent(WidgetDisplay display) {
removeContent();
content = display.asWidget();
panel.add(display.asWidget(), DockPanel.CENTER);
}

@Override
public void addHeader(WidgetDisplay display) {
panel.add(display.asWidget(), DockPanel.NORTH);
}
@Override
public void removeContent() {
if (content != null) {
panel.remove(content);
}
}
...
}

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate