/** * Injects the various resources and performs other bindings. * * <p>Never call directly, it should only be called by GIN. Method injection is used instead of * constructor injection, because the latter doesn't work well with GWT generators. * * @param placeManager The {@link PlaceManager}. * @param eventBus The {@link EventBus}. */ @Inject protected void bind(final PlaceManager placeManager, EventBus eventBus) { this.eventBus = eventBus; this.placeManager = placeManager; eventBus.addHandler( PlaceRequestInternalEvent.getType(), new PlaceRequestInternalHandler() { @Override public void onPlaceRequest(PlaceRequestInternalEvent event) { if (event.isHandled()) { return; } PlaceRequest request = event.getRequest(); if (matchesRequest(request)) { event.setHandled(); if (canReveal()) { handleRequest(request, event.shouldUpdateBrowserHistory()); } else { event.setUnauthorized(); } } } }); eventBus.addHandler( GetPlaceTitleEvent.getType(), new GetPlaceTitleHandler() { @Override public void onGetPlaceTitle(GetPlaceTitleEvent event) { if (event.isHandled()) { return; } PlaceRequest request = event.getRequest(); if (matchesRequest(request)) { if (canReveal()) { event.setHandled(); getPlaceTitle(event); } } } }); }
/** * Obtains the title for this place and invoke the passed handler when the title is available. By * default, places don't have a title and will invoke the handler with {@code null}, but override * this method to provide your own title. * * @param event The {@link GetPlaceTitleEvent} to invoke once the title is available. */ protected void getPlaceTitle(GetPlaceTitleEvent event) { event.getHandler().onSetPlaceTitle(null); }