Friday, March 8, 2013

Drop Down Date Picker In GWTP for Dummies

Drop Down Date Picker In GWTP for Dummies

 

This is one of the way to implement date picker functionality, which I found easy to implement and understand.

This calls server when it is initiated first time to get the Year from the server. Since, I dont want date picker to get the year details from client machine.



Thursday, January 31, 2013

Internationalization in GWT UiBinder For Dummies

Internationalization in GWT UiBinder For Dummies



Supporting Multilingual in GWT is simple and very few steps to follow.

<ui:msg> tag for text to support multilingual as shown below.

<ui:msg key="street1" description="Address Street1">Street1</ui:msg>

here key attribute is optional (GWT will create random key if you didn't use key attribute), but its highly recommended to use a key.

while compiling the gwt project, pass -extra <folder_name> argument to the compiler, it will create  properties files for each uibinder files inside the directory with <folder_name>.

1. Properties file with package name can be found eg: com.gwt.sample.client.content.SkillsetDialogViewBinderImplGenMessages.properties

2. Delete package name in the file, eg: SkillsetDialogViewBinderImplGenMessages.properties

3. Place it in the proper package(in the above case, the file must be place in  com.gwt.sample.client.content package

4. Try changing the properties file name (eg: SkillsetDialogViewBinderImplGenMessages_fr.properties for french) for locales and modify the values for each key accordingly.

5. Change the language in browser or pass the language in the URL like below :

http://127.0.0.1:8888/Project.html?gwt.codesvr=127.0.0.1:9997&locale=fr




Monday, January 21, 2013

Dialog Box in GWTP for Dummies

Dialog Box in GWTP  for Dummies


One of the important thing in GWT is Dialog box, which will enable user to get alerted, prompt messages, helped to give input to application etc...

Its very simple creating a dialog box in GWTP, create a Presenter with PopupView and inject the presenter into the place (Parent Presenter) it is required based on the event in Parent presenter.

The example show a simple dialog box appear for the button click event in mail window.

<g:DialogBox width="" glassEnabled="true" animationEnabled="true"
modal="true">
<g:caption>This is Heading</g:caption>
<g:HTMLPanel width="400px" height="200px">
<g:VerticalPanel spacing="10" horizontalAlignment="ALIGN_CENTER"
width="100%" height="100%" verticalAlignment="ALIGN_MIDDLE">
<g:Button width="150px" height="30px" ui:field="close"> Close Me!!!</g:Button>
</g:VerticalPanel>
</g:HTMLPanel>
</g:DialogBox>

Dialog box in this example is Modal and with glass enable is set to true to make the user not to navigate in rest of the window other than Dialog box.







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.