I am trying to do a transition to GWTP with my already existing application. However, I am having some troubles figuring out how to have a secured and an unsecured area for it.
The case is simple: I am having a landing page and an admin page which both have entirely different skeletons (menu, side nav, main content, etc.).
To make it simpler, these are my current module implementations:
What I am actually having in my ApplicationView
UiBinder is this:
which is a public static UI field of ApplicationView
:
public static @UiField SimplePanel mainContentWrapper;
What I do now is setting the actual content inside of the onReveal()
method of the two presenter AdminToolPresenter
and LangingPresenter
like this:
@Inject
AdminToolPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
super(eventBus, view, proxy, ApplicationPresenter.SLOT_AdminMainContent);
}
@Override
protected void onReveal() {
super.onReveal();
ApplicationView.mainContentWrapper.setWidget(this.getView());
}
and
@Inject
LandingPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
super(eventBus, view, proxy, ApplicationPresenter.SLOT_LandingMainContent);
}
@Override
protected void onReveal() {
super.onReveal();
ApplicationView.mainContentWrapper.setWidget(this.getView());
}
Please note how I bind ApplicationPresenter.SLOT_AdminMainContent
and ApplicationPresenter.SLOT_LandingMainContent
respectively.
Since GWTP is actually a pretty smart tool I want to make sure that I am using it correctly.
Therefore I'd like to know if I do this the way it is intended to be or if GWTP actually provides a smarter solution to this problem?
This question rises especially since I am not sure yet how navigation is actually going to be handled.
There is no need to call ApplicationView.mainContentWrapper.setWidget(this.getView())
in your onReveal
method.
GWTP
should take care of that either by using bindSlot(ApplicationPresenter.SLOT_LandingMainContent, mainContentWrapper)
in your ApplicationView
constrcutor or by overriding the setInSlot
or addToSlot
method in your ApplicationView
. (see the SLOTS documentation)
You will also want to use a Gatekeeper to secure your AdminToolPresenter
.