I'm chewing on this quite long now. I'm not getting it ..
I'm having a NavBarPresenter:
public class NavBarPresenter extends Presenter<NavBarPresenter.MyView, NavBarPresenter.MyProxy> implements NavBarUiHandlers {
private final static Logger LOGGER = Logger.getLogger(NavBarPresenter.class.getName());
interface MyView extends View , HasUiHandlers<NavBarUiHandlers> {
public static final Type<RevealContentHandler<?>> SLOT_NavBar = new Type<RevealContentHandler<?>>();
interface MyProxy extends Proxy<NavBarPresenter> {
NavBarPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
super(eventBus, view, proxy, MenuPresenter.SLOT_NavBar);
this.getView().setUiHandlers(this);
LOGGER.severe("NavBarPresenter()");
and the corresponding view:
class NavBarView extends ViewWithUiHandlers<NavBarUiHandlers> implements NavBarPresenter.MyView {
private final static Logger LOGGER = Logger.getLogger(NavBarView.class.getName());
interface Binder extends UiBinder<Widget, NavBarView> {
}
@UiField
SimplePanel main;
@Inject
NavBarView(Binder uiBinder) {
this.initWidget(uiBinder.createAndBindUi(this));
LOGGER.severe("NavBarView()");
this.bindSlot(MenuPresenter.SLOT_NavBar, this.main);
}
@Override
public void setInSlot(Object slot, IsWidget content) {
if (slot == NavBarPresenter.SLOT_NavBar) {
this.main.setWidget(content);
} else {
super.setInSlot(slot, content);
}
}
}
And this is how I try to show my navigation bar in prepareFromRequest as part of a place:
public class ShopPresenter extends Presenter<ShopPresenter.MyView, ShopPresenter.MyProxy> implements ShopUiHandlers {
private final static Logger LOGGER = Logger.getLogger(ShopPresenter.class.getName());
interface MyView extends View , HasUiHandlers<ShopUiHandlers> {
}
@NameToken(AdminNameTokens.shop)
@ProxyStandard
interface MyProxy extends ProxyPlace<ShopPresenter> {
}
@SuppressWarnings("unused")
private NavBarPresenter navBarPresenter;
private MenuPresenter menuPresenter;
@Inject
ShopPresenter(EventBus eventBus, MyView view, MyProxy proxy, MenuPresenter menuPresenter, NavBarPresenter navBarPresenter) { super(eventBus, view, proxy, AdminToolPresenter.SLOT_AdminToolMainContent);
this.menuPresenter = menuPresenter;
this.navBarPresenter = navBarPresenter;
this.getView().setUiHandlers(this);
}
@Override
public void prepareFromRequest(PlaceRequest request) {
this.menuPresenter.setInSlot(MenuPresenter.SLOT_NavBar, this.navBarPresenter);
}
}
but I'm not seeing anything. No warning or exception it's just not doing anything. All in all I am trying to accomplish this:
So what I have is this: There are different places which can be visited using a *side* navigation.
Place A
Place B
Place C
each of these places require a different navigation bar to be rendered in a `navBarPanel` widget which is held in a `MenuView`.
@UiField HTMLPanel navBarPanel;
@Inject MenuView(Binder uiBinder, PlaceManager placeManager) {
this.initWidget(uiBinder.createAndBindUi(this));
this.bindSlot(MenuPresenter.SLOT_NavBar, this.navBarPanel);
}
But there is more. Some places have "sub-places" which can be introduced by a certain navigation bar e.g. if you click on the link to `Place B` then the navigation bar (not the *side* nav) will show you two links `Place B-1` and `Place B-2`.
My I essentially would like to know:
- What is the GWTP way to *update* the navigation bar? By that I mean that if I visit one of the sub places e.g. `Place B-1` using a bookmark, then the correct navigation bar needs to be rendered in the slot `MenuPresenter.SLOT_NavBar`.
- What kind of slot do I have to use for such a navigation widget or can I create e.g. a navigation bar which is a place but is listening to multiple places. What I mean is it could "react" to a set of places `Place B`, `Place B-1` and `Place B-2` and draws itself into the predefined slot whenever one of these places are getting navigated to.
I'm currently trying different things but none of them work. I can't even get the navigation bar being drawn in the slot.
Could somebody guide me throw this?