best practices in ext gwt

33
Ext GWT Best Practices in Ext GWT DARRELL MEYER, SENCHA Monday, November 29, 2010

Upload: sencha

Post on 20-Jan-2015

4.147 views

Category:

Technology


0 download

DESCRIPTION

Ext GWT provides a solid foundation to build rich internet applications. In this session, you will learn the best practices used to build these applications. Topics include how to use HTML templates and HtmlLayout, MVC / MVP, RPC, and managing data.

TRANSCRIPT

Page 1: Best Practices in Ext GWT

Ext GWTBest Practices in Ext GWT

DARRELL MEYER, SENCHA

Monday, November 29, 2010

Page 2: Best Practices in Ext GWT

OverviewXTemplate & HtmlContainer

LayoutsRPC

Dependency InjectionMVP

Monday, November 29, 2010

Page 3: Best Practices in Ext GWT

Conference App

Monday, November 29, 2010

Page 4: Best Practices in Ext GWT

Ext GWT 2.2.1GWT 2.1

Java Persistence API (JPA)Google App Engine (GAE)

RequestFactoryGWT MVPDependency Injection with Gin

Download at http://dev.sencha.com/playpen/gxt/conference-app.zip

Technology Stack

Monday, November 29, 2010

Page 5: Best Practices in Ext GWT

Eclipse IDE for Java EE Developers (Helios 3.6.1)http://www.eclipse.org/downloads/

PluginsMaven Integration for Eclipsehttp://m2eclipse.sonatype.org/sites/m2e

Maven Integration for Eclipse WTP Integrationhttp://m2eclipse.sonatype.org/sites/m2e-extras

Google Eclipsehttp://code.google.com/eclipse/

IDE & Plugins

Monday, November 29, 2010

Page 6: Best Practices in Ext GWT

XTemplate &

HtmlContainer

Monday, November 29, 2010

Page 7: Best Practices in Ext GWT

Avoid using Widgets for layoutPanels and Containers are slowRendering HTML fragments is fastA small amount of HTML and CSS can go a long long way

Templating in General

Monday, November 29, 2010

Page 8: Best Practices in Ext GWT

Advanced templatingApply HTML fragments to your dataFeaturesFormattingAuto filling lists using templates and sub-templatesConditional processing with basic comparator operatorsBasic math function supportExecute arbitrary inline code with special built-in template variables

XTemplate

Monday, November 29, 2010

Page 9: Best Practices in Ext GWT

Direct support in ComponentsListViewComboBoxRowExpanderColorPaletteGenerate content for any element

XTemplate Usage

Monday, November 29, 2010

Page 10: Best Practices in Ext GWT

XTemplate Example

Monday, November 29, 2010

Page 11: Best Practices in Ext GWT

HtmlContainerInserts widgets into arbitrary HTML markupSupports three modes for container contentExisting ElementFrom CodeRequestBuilder

Monday, November 29, 2010

Page 12: Best Practices in Ext GWT

HtmlContainer Example

Monday, November 29, 2010

Page 13: Best Practices in Ext GWT

Layouts

Monday, November 29, 2010

Page 14: Best Practices in Ext GWT

Use the fewest Layouts as possibleGood for laying large sections of an applicationNot as good for showing detailed information

Layouts

Monday, November 29, 2010

Page 15: Best Practices in Ext GWT

Layouts Hierarchy

Layout

Column Fit Row

Absolute Form VBox HBox Accordian Card Fill

Anchor

Size

Size & Position

Append

Flow Table

TableRow

Border Box

Monday, November 29, 2010

Page 16: Best Practices in Ext GWT

Layouts are powerful as layout execution can cascadeWhen containers are resized they execute their layoutIf a child of a container is resized by layout, it will execute its layout

Cascading Layouts

ViewportBorderLayout

ContentPanelFitLayout

ContentPanelRowLayout

ToolBar GridTabPanel

TabItem

ContentPanelFlowLayout

Grid

NOT RESIZED

Monday, November 29, 2010

Page 17: Best Practices in Ext GWT

Inspect the DOM using tool such as FirebugResize browser or panelsNotice changes in DOM (width, height, top, left, etc)

Monitoring Layouts

Monday, November 29, 2010

Page 18: Best Practices in Ext GWT

Monitoring Layouts

Monday, November 29, 2010

Page 19: Best Practices in Ext GWT

RPC

Monday, November 29, 2010

Page 20: Best Practices in Ext GWT

RPC will return entire object graphOnly return what you need for the given screen

RPC Best Practices

Monday, November 29, 2010

Page 21: Best Practices in Ext GWT

Always check GWT serialization file (*.gwt.rpc)Do not expose Object in RPC service interfaceBlacklist

RPC Serialization Policy

Monday, November 29, 2010

Page 22: Best Practices in Ext GWT

Dependency Injection

Monday, November 29, 2010

Page 23: Best Practices in Ext GWT

Automatic dependency injectionAvoid FactoriesAvoid use of new in your code

GIN (client) and Guice (server)http://code.google.com/p/google-guice/http://code.google.com/p/google-gin

Dependency Injection

Monday, November 29, 2010

Page 24: Best Practices in Ext GWT

Avoid using “new”Avoid Factories

Without DI

Monday, November 29, 2010

Page 25: Best Practices in Ext GWT

Extend Ginjector and define DI interface

GIN Example

Monday, November 29, 2010

Page 26: Best Practices in Ext GWT

Extend Ginjector and define DI interface

GIN Example

Monday, November 29, 2010

Page 27: Best Practices in Ext GWT

public class ConferenceModule extends AbstractGinModule {

@Override protected void configure() { bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); bind(ConferenceRequestFactory.class).toProvider(RequestFactoryProvider.class).in(Singleton.class); bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class); bind(DataLoaderAsync.class).toProvider(DataLoadControllerProvider.class).in(Singleton.class); bind(SessionListView.class).to(SessionListViewImpl.class).in(Singleton.class); bind(SessionDetailView.class).to(SessionDetailViewImpl.class).in(Singleton.class); }

static class PlaceControllerProvider implements Provider<PlaceController> {

private final EventBus eventBus;

@Inject public PlaceControllerProvider(EventBus eventBus) { this.eventBus = eventBus; }

public PlaceController get() { return new PlaceController(eventBus); } } }

GIN Example

Monday, November 29, 2010

Page 28: Best Practices in Ext GWT

public class ConferenceApp {

private static final Logger log = Logger.getLogger(ConferenceApp.class.getName());

private ConferenceRequestFactory requestFactory; private EventBus eventBus; private PlaceController placeController; private ConferenceDesktopShell shell; private Place defaultPlace = new SessionListPlace(); private SessionListView sessionListView; private SessionDetailView sessionDetailView; private DataLoaderAsync service;

@Inject public ConferenceApp(ConferenceDesktopShell shell, DataLoaderAsync service, ConferenceRequestFactory requestFactory, EventBus eventBus, PlaceController placeController) { this.shell = shell; this.service = service; this.requestFactory = requestFactory; this.eventBus = eventBus; this.placeController = placeController; }

GIN Example

Monday, November 29, 2010

Page 29: Best Practices in Ext GWT

Change implementation based on user agent / device

GIN Example

Monday, November 29, 2010

Page 30: Best Practices in Ext GWT

Change implementation based on user agent / device

GIN Example

Monday, November 29, 2010

Page 31: Best Practices in Ext GWT

MVP

Monday, November 29, 2010

Page 32: Best Practices in Ext GWT

Presenters / ActivitiesViewsPlacesPlace History MappersActivity Mappers

MVP Example

Monday, November 29, 2010

Page 33: Best Practices in Ext GWT

Thanks!Twitter @darrellmeyer

Portions of this presentation from the GWT documentation licensed under the Creative Commons Attribution 3.0 License

Monday, November 29, 2010