Sunday, December 30, 2012

Gate Keepers In GWTP for Dummies


Gate Keepers In GWTP for Dummies


Gate Keeper, used to restrict the unauthorized user from the viewing the presenter.
the presenter which are supposed to be protected must use the GateKeeper implementation annotated in there proxy interface.

The implementation class must override canReveal() method of GateKeeper interface.

Annotate Proxy interface of Presenter using @UseGatekeeper with specific GateKeeper implementation class.

Provide a method in Ginjector for accessing the GateKeeper.

SampleGateKeeper getSampleGateKeeper();

Try to access http://localhost:7070/sample/#restrict URL, which will redirected to error page.

Thats it!!!

Error Place In GWTP For Dummies

Error Place In GWTP For Dummies

 

  Error place is to display the appropriate error message, when the client is trying to access the page that doesn't exists.

  You have to override revealErrorPlace(String invalidHistoryToken) in ClientPlaceManager which extends PlaceManagerImpl and redirect the request to error page using PlaceRequest as mentioned below.

@Override
public void revealErrorPlace(String invalidHistoryToken){
PlaceRequest placeRequest = new  PlaceRequest(NameTokens.error);
revealPlace(placeRequest);
}

Enter : http://localhost:7070/sample/#notexist any place name which doesn't exist.

you will see, http://localhost:7070/sample/#error


Saturday, December 29, 2012

GWTP Event - EventBus For Dummies

 

GWTP Event - EventBus For Dummies

Event : any kind of action performed in the GWT Application/Window is an event.

EventBus : Which carries the event to different part of the application for handling event with corresponding event Handlers.

The best things here is the handlers doesn't know from where the event has been fired. Only task for handlers is to look for events and handle it!!!.

In the sample program. Event is generated from ContentMenuPresenter and Handled in ContentPresenter.

Sample



Friday, December 28, 2012

PresenterWidget In GWTP For Dummies


PresenterWidget In GWTP For Dummies


Presenter widgets are pluggable components in GWTP framework.

Create it and insert into any place you want in the GWT application.

Basically, you need to call setInSlot() method to insert into a slot of the Presenter (SetInSlot() method in Container Presenter).

Sample project creates a Container Presenter and all the (ContentMenuPresenter, ContentHeaderPresenter, ContentFooterPresenter) Presenter Widgets are inserted into Container Presenter when it loads (reveals, revealInParent() method of Container Presenter).

Container Presenter is not a place, so you can’t reveal it with the help of URL. So you have to create Presenter which is a place. In this case, it’s ProfileOverviewPresenter with place token as “profile”. (Append #profile) to URL.

Then, revealInParent() method of ProfileOverviewPresenter call RevealContentEvent.fire(this, ContentContainerPresenter.MAIN_CONTENT_SLOT, this); which will reveal it parent, which is Container Presenter.

The Reveal Event for Container presenter is RevealRootLayoutContentEvent.fire(this, this); and not RevealRootContentEvent, Please note this.

The Reveal Event for ProfileOverviewPresenter is RevealContentEvent.fire(this, ContentContainerPresenter.MAIN_CONTENT_SLOT, this);.

Section Colors might irritate you, please don't mind.