Hi
Very new to GWT and MVP. Trying to expand the contacts example with a
DockLayoutPanel with a tree navigation in the west section. Using MVP
and ui:bindings.
Got an DockLayoutPanelView and Presenter. Inside is a tree component
to the west and a content component in center. How will I get the
events from the tree component?
My DockViewPresenter:
public class DockPresenter implements Presenter {
public interface Display {
Widget asWidget();
}
private final ContactsServiceAsync rpcService;
private final HandlerManager eventBus;
private final Display display;
private ContactsPresenter contactsPresenter;
private TreePresenter treePresenter;
public DockPresenter(ContactsServiceAsync rpcService,
HandlerManager eventBus, Display view) {
this.rpcService = rpcService;
this.eventBus = eventBus;
this.display = view;
contactsPresenter = new ContactsPresenter(rpcService, eventBus,
new ContactsView());
treePresenter = new TreePresenter(rpcService, eventBus, new
MyTree());
}
public void bind() {
contactsPresenter.bind();
treePresenter.bind();
}
public void go(final HasWidgets container) {
bind();
container.clear();
container.add(display.asWidget());
}
}
As you can see I am creating the two presenters for the content and
the tree, but I dont know how to get the events (clicks, selections)
from them. They seem to be swallowed be the dock. I'm guessing I
should register handlers in the bind() method, but how? When
navigating to the tree component without the dock, events works fine.
TreePresenter:
public class TreePresenter implements Presenter {
public interface Display {
HasSelectionHandlers<TreeItem> getTree();
Widget asWidget();
}
private final ContactsServiceAsync rpcService;
private final HandlerManager eventBus;
private final Display display;
public TreePresenter(ContactsServiceAsync rpcService, HandlerManager
eventBus, Display view) {
this.rpcService = rpcService;
this.eventBus = eventBus;
this.display = view;
}
public void bind() {
display.getTree().addSelectionHandler(new
SelectionHandler<TreeItem>() {
public void onSelection(SelectionEvent<TreeItem> event) {
TreeItem item = (TreeItem) event.getSelectedItem();
GWT.log("Node selected "+item.getText());
}
});
}
Thanks
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.