I have been working with implementing the MVP pattern while making use of the GWT-EXT library.
I was inspired by David Chandler’s technique for hide/showing DIV’s when switching between distinct views in the application. Because GWT-EXT uses a Viewport object to serve as the root panel on the page, David’s exact technique didn’t work out with GWT-EXT panels. The solution turns out to be to create a new Viewport on each change of the root view. In my case I simply implemented hide() and show() methods in my display to take care of this.
public void hide() { panel.setVisible(false); } public void show() { Log.debug("in UserView.show"); panel.setVisible(true); new Viewport(panel); }
In my case, panel represents the root panel for the view. My impression of Viewport is that the documentation is scarce and it is a mysery as to exactly how it manages the browser window. Perhaps there is more documentation in the underlying JS library but I didn’t go that far.
The other issue I’ve faced with GWT-EXT is that GWT-EXT aren’t always the same as GWT widgets and do not normally implement interfaces like HasClickHandlers, HasHTML, etc. I may work on extending GWT-EXT’s button to work with HasClickHandlers.
One handy feature of GWT-EXT’s Panel is the ability to add a Toolbar to the bottom or top. Immediately though I wanted to add a GWT Hyperlink. Here GWT-EXT expects controls added to the Toolbar class to derive from ToolbarItem. Eventually I discovered it is possible to add items to a Toolbar by DOM element:
private void initToolbar() { PlaceRequest placeRequestManageUsers = new PlaceRequest(UserPresenter.PLACE); linkManageUsers = new Hyperlink("Manager users", placeRequestManageUsers.toString()); /** * call to addFill() makes toolbar right justify */ toolbar.addFill(); toolbar.addElement(linkManageUSers.getElement()); ... }
After so many years of programming in Struts I have to admit that programming in GWT represents a new way of thinking. Designing for the user experience that is possible with GWT is a welcome change of pace after so much page-oriented stuff in traditional Struts.
You must be logged in to post a comment.