Hi Thomas Thanks for your reply, I have started to look into the ActivityManager and Place patterns, but have not found lots of documentation. Is there any examples? Is gwt-p going to be standard for 2.1 or will google release there own implementation?
Thanks On 14 Juli, 17:07, Thomas Broyer <t.bro...@gmail.com> wrote: > On 8 juil, 10:39, xworker <blomqvist.andr...@gmail.com> wrote: > > > 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? > > The generally adopted way of doing things in GWT is to have custom > events go through the event bus. In this case, you're talking about > "navigation", so maybe the concept of "place" would be better than > "just" some custom event. I encourage you to look at gwt-platform, gwt- > presenter and other MVP frameworks for GWT, and/or look at the > Activity concept from the upcoming GWT 2.1. > > Using actvities, you'd have an ActivityManager managing your "center". > The tree would use the PlaceController.goTo to navigate to a new > "place". An ActivityMapper (that you passed to the ActivityManager in > the constructor) would map the place to an Activity (a presenter), and > the ActivityManager will manage the current Activity for the display > it manages, i.e.it will stop() the current activity if its ok > (willStop returns true) and then only start the new Activity, which > will call the Display back to show its view. > The tree would probably also listen to PlaceChangeEvent on the event > bus to update the selected item depending on the current place (in > case some other component calls the PlaceController.goTo) > > > > > 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- Dölj citerad text - > > - Visa citerad text - -- 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-tool...@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.