SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
Js as a target language: 
GWT KickOff (Part 2/2) 
Alberto Mancini - alberto@jooink.com 
Francesca Tosi - francesca@jooink.com
Alberto Mancini 
alberto@jooink.com 
http://github.com/jooink 
http://www.jooink.com 
http://jooink.blogspot.com
Francesca Tosi 
francesca@jooink.com 
+FrancescaTosi 
@francescatosi 
http://github.com/jooink 
http://www.jooink.com 
http://jooink.blogspot.com
GWT 
GWT is a toolkit to develop Ajax web 
application with Java. 
The programmer writes Java code and this 
code is translated into HTML and Javascript via 
the GWT compiler. 
The compiler creates browser specific HTML 
and JavaScript to support all the major 
browsers correctly.
setup 
1. java sdk: http://www.java.com/it/download/ (e.g 1.7) 
2. eclipse: http://www.eclipse.org/downloads/ (e.g. EE) 
3. GWT Eclipse Plugin: 
https://developers.google.com/eclipse/docs/getting_started 
4. Create simple project 
5. run ‘dev mode’ 
6. open in browser http://127.0.0.1:8888/?get. 
condeserv=127.0.0.1:9997 
(install browser plugin)
GWT cont'd - Tools in the Toolkit 
+ GWTc, compiler Java to Javascript 
+ Emulated JRE 
+ Web UI class library (Widgets) 
+ Eclipse Plugin, SpeedTracer, Designer 
It's open source, completely free, and used by 
thousands of developers around the world (in 
Google AdWords,Orkut,Blogger,Groups)
Toolkit != Framework 
Frameworks that may help 
https://github.com/ArcBees/GWTP 
model-view-presenter framework 
http://www.jboss.org/errai 
CDI, and JPA for GWT 
http://www.tessell.org/ 
app framework (on gwt-pectin)
GWT cont'd - Developing & Running 
GWT provides two (3 actually) modes 
● Development Mode: allows to debug the 
Java code of your application directly via the 
standard Java debugger. 
● Web mode: the application is translated into 
HTML and Javascript code and can be 
deployed to a webserver. 
● SuperDevMode
GWT cont'd - Why ? 
Typed Language 
Well Known Programming Framework 
Optimize 
Browser Independence (quite, almost) 
+ 
'Native' through jsni 
Move Objects between client and server
GWT cont'd - History 
● GWT 1.0 (2006) 
● GWT 1.3 (2007) First Open Source Release, OSX support 
● GWT 1.4 (2007) JUnit and ImageBundle 
● GWT 1.5 (2008) Java 1.5 support, Overlay Types, DOM API, CSS 
Themes, Linkers 
● GWT 1.6 (2009) EventHandlers, EMMA Support, WAR support, 
Parallelized Builds 
● GWT 1.7 (2009) Newer browser support, IE8, GPE and AppEngine 
● GWT 2.0 (2009) DevMode, DraftCompile, UIBinder, LayoutPanel, 
CodeSplitter, ClientBundle, CssResource 
● GWT 2.1 (2010) RequestFactory, Editor Framework, Validation, MVP, Cell 
Widgets 
● GWT 2.2 (2011) GWT Designer, HTML5 support 
● GWT 2.3 (2011) Better AppEngine integration 
● GWT 2.4 (2011) Maven and RequestFactory enhancements 
● GWT 2.5 (2012) SuperDevMode, Elemental, UiRenderers, 
FragmentMerging, ClosureCompiler
GWT cont'd - History 
● GWT 2.5.1 (2013) - bugfixes and optimizations 
● GWT 2.6.0 (2014) - java 7 - IE10 - Internet Explorer cleanup: IE6/7 
● GWT 2.6.1 (2014) - working on Super Dev Mode 
Annual Vaadin “The Future of GWT Report” 
https://vaadin.com/gwt/report-2013 
What’s going on. 
SuperDevMode 
Java8 
JsInterop 
GSS
GWT cont'd - Open Source Project 
The GWT Steering committee was founded in 2012 to help 
the GWT project become an even bigger success as an 
open source project. 
● Ray Cromwell, Google 
● Artur Signell, Vaadin 
● Colin Alworth, Sencha 
● Mike Brock, RedHat 
● Thomas Broyer 
● Stephen Haberman, Bizo 
● Daniel Kurka, Google 
● Christian Goudreau, Arcbees 
● Konstantin Solomatov, Jetbrains
Anatomy 
Module html file 
Module xml file 
translatable directories
Modules 
Individual units of GWT configuration are called modules. A 
module bundles together all the configuration settings that a 
GWT project needs: 
● inherited modules 
● an entry point application class name; these are optional, 
although any module referred to in HTML must have at 
least one entry-point class specified 
● source path entries 
● public path entries 
● deferred binding rules, including property providers 
and class generators
Deferred Binding 
Deferred Binding is a feature of the GWT compiler that 
works by generating many versions of code at compile 
time, only one of which needs to be loaded by a particular 
client during bootstrapping at runtime. 
Each version is generated on a per browser basis, along 
with any other axis that your application defines or uses. 
RPC Calls 
Widgets tuned for specific browsers 
Internationalization
Deferred Binding cont'd 
Deferred binding has several benefits: 
● Reduces the size of the generated JavaScript code that 
a client will need to download by only including the code 
needed to run a particular browser/locale instance (used 
by the Internationalization module) 
● Saves development time by automatically generating 
code to implement an interface or create a proxy class 
(used by the GWT RPC module) 
● Since the implementations are pre-bound at compile 
time, there is no run-time penalty to look up an 
implementation in a data structure as with dynamic 
binding or using virtual functions.
conditional compilation - replacement 
A type is replaced with another depending on a 
set of configurable rules. 
IType = GWT.create(TypeImpl.class); 
<replace-with class="...TypeImplFirefox"> 
<when-type-is class="...TypeImpl" /> 
<when-property-is 
name="user.agent" value="gecko"/> 
</replace-with>
properties & property providers 
<property-provider name="property_name"> 
Define a JavaScript fragment that will return the value for the named property at 
runtime. 
//mobilewebapp sample 
<define-property name="formfactor" values="desktop,tablet,mobile"/> 
<collapse-property name="formfactor" values="*"/> 
<property-provider name="formfactor"> 
<![CDATA[ 
.... return (size < 6) ? "mobile" : "tablet"; ... 
return "desktop"; 
]]>
Generators 
Generators are classes that are invoked by the 
GWT compiler to generate a Java 
implementation of a class during compilation 
<generate-with class="...XYGenerator"> 
<when-type-assignable class="...XYType" /> 
</generate-with> 
</module> 
XYType=GWT.create(...); (e.g. RPC, UiBinder)
Generator Class 
Defining a subclass of the Generator class is 
like defining a plug-in to the GWT compiler. 
public class XYGenerator extends Generator { 
public String generate(TreeLogger logger, 
GeneratorContext ctx, 
String requestedClass) 
throws UnableToCompleteException { 
... 
} 
}
emulated JRE 
GWT includes a library that emulates a subset 
of the Java runtime library. 
http://www.gwtproject. 
org/doc/latest/RefJreEmulation.html 
InputStream 
Threads ?
<super-source> 
The <super-source> tag instructs the compiler 
to "re-root" a source path. This is useful for 
cases where you want to re-use an existing 
Java API for a GWT project, but the original 
source is not available or not translatable. 
A common reason for this is to emulate part of 
the JRE not implemented by GWT.
JSNI 
GWT borrows from the Java Native Interface 
(JNI) concept to implement JavaScript Native 
Interface (JSNI). 
Writing JSNI methods is a powerful technique, 
but should be used sparingly because writing 
bulletproof JavaScript code is notoriously tricky. 
Needed for JSO (Javascript Overlay Types)
JSNI cont'd 
public static native void alert(String msg) /*-{ 
$wnd.alert(msg); 
}-*/; 
$wnd: the root browser window GWT widgets 
are being rendered to 
$entry(..): method that makes code reentry 
safe. 
http://www.lustforge.com/2012/11/11/gwt-jsni-variables-an-exhaustive-list/ 
http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html
Widgets 
UiComponents 
http://www.gwtproject.org/doc/latest/RefWidgetGallery.html 
2.0+ LayoutPanels 
http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html#LayoutPanels 
from the Jul 2013 - GWT Meetup 
What are some of pain points or decisions bad in hindsight? 
... 
● Bad out of box UI 
... 
SmartGWT, GXT
UiBinder 
● The UiBinder is a framework designed to separate Functionality and View 
of User Interface. 
● The UiBinder framework allows developers to build gwt applications as 
HTML pages with GWT widgets configured throughout them. 
● The UiBinder framework makes easier collaboration with UI designers who 
are more comfortable with XML, HTML and CSS than Java source code 
● The UIBinder provides a declarative way of defining (parts of the) User 
Interface. 
● The UIBinder seperates the programmic logic from UI. 
● The UIBinder is similar to what JSP is to Servlets.
UiBinder cont'd 
DSL (xml) to lay-out (declaratively) widgets 
no loops, no conditionals, no if statements 
UiBinder allows you to lay out your user 
interface. 
(offers direct support for internationalization)
UiBinder - syntax 
<!-- HelloWidgetWorld.ui.xml --> 
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' 
xmlns:g='urn:import:com.google.gwt.user.client.ui'> 
<g:HTMLPanel> 
Hello, <g:ListBox ui:field='listBox' visibleItemCount='1'/>. 
</g:HTMLPanel> 
</ui:UiBinder> 
xmlns:g='urn:import:..' binds package to namespace 
ui:field gives name to the widget 
Every one of the widget's methods that follow JavaBean-style conventions for 
setting a property can be used: 
visibleItemCount transl. as setVisibleItemCount(...)
UiBinder - syntax 
public class HelloWidgetWorld extends Composite { 
interface MyUiBinder extends UiBinder<Widget, HelloWidgetWorld> {} 
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); 
@UiField ListBox listBox; 
public HelloWidgetWorld(String... names) { 
// sets listBox 
initWidget(uiBinder.createAndBindUi(this)); 
for (String name : names) { 
listBox.addItem(name); 
} 
} 
}
UiBinder - misc 
uses the default (with no args) constructor 
@UiField(provided=true) [or read the docs] 
can associate handlers 
@UiHandler("button") 
void handleClick(ClickEvent e) { ..... } 
can inject any type (inst'd through GWT.create) 
<ui:with field='res' type='...'/>
UiBinder - ui:style 
With the <ui:style> element, you can define the 
CSS for your UI right where you need it. 
<ui:style> 
.example { background-color: red } 
</ui:style> 
... 
<g:HTML addStyleNames="{style.red}"/> 
...
UiBinder - ui:style 
<ui:style src="MyUi.css" /> 
<ui:style field='oStyle' src="MyUiOStyle.css"> 
<ui:style type='com.my.app.MyFoo.MyStyle'> 
@UiField 
MyStyle style; 
(CssResource oStyle)
CssResource 
interface MyStyle extends CssResource { 
String enabled(); 
String disabled(); 
} 
@UiField 
MyStyle style; 
style.enabled() (class name) 
http://www.gwtproject.org/javadoc/latest/com/google/gwt/resources/client/CssResource.html
ClientBundle 
public interface Resources extends ClientBundle { 
@Source("Style.css") 
Style style(); 
@Source("Logo.jpg") 
ImageResource logo(); 
public interface Style extends CssResource { 
String mainBlock(); 
String nameSpan(); 
Sprite userPictureSprite(); 
} 
}
GWT-RPC 
BY EXAMPLE
Thanks 
Alberto Mancini 
alberto@jooink.com 
Francesca Tosi 
francesca@jooink.com

Mais conteúdo relacionado

Mais procurados

Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)Hyungwook Lee
 
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with QtICS
 
Counterclockwise past present future
Counterclockwise  past present futureCounterclockwise  past present future
Counterclockwise past present futurelolopetit
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3Opersys inc.
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the expertsICS
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQICS
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing moreICS
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.JooinK
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010JUG Lausanne
 
2013 04-02-server-side-backbone
2013 04-02-server-side-backbone2013 04-02-server-side-backbone
2013 04-02-server-side-backboneSC5.io
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015jbandi
 
WebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolutionWebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolutionjuanjosanchezpenas
 
Testing cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestTesting cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestMicael Gallego
 
GWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouGWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouRobert Cooper
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Opersys inc.
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to QtJanel Heilbrunn
 
An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018ICS
 
Qt for Python
Qt for PythonQt for Python
Qt for PythonICS
 
Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt ICS
 

Mais procurados (20)

Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)
 
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
 
Counterclockwise past present future
Counterclockwise  past present futureCounterclockwise  past present future
Counterclockwise past present future
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the experts
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQ
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing more
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.
 
YaJUG: What's new in GWT2
YaJUG: What's new in GWT2YaJUG: What's new in GWT2
YaJUG: What's new in GWT2
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
 
2013 04-02-server-side-backbone
2013 04-02-server-side-backbone2013 04-02-server-side-backbone
2013 04-02-server-side-backbone
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015
 
WebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolutionWebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolution
 
Testing cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestTesting cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTest
 
GWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouGWT 2 Is Smarter Than You
GWT 2 Is Smarter Than You
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to Qt
 
An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018
 
Qt for Python
Qt for PythonQt for Python
Qt for Python
 
Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt
 

Semelhante a Javascript as a target language - GWT KickOff - Part 2/2

GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)firenze-gtug
 
Gwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca TosiGwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca Tosifirenze-gtug
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13Fred Sauer
 
GWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO ToolsGWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO Toolsbarciszewski
 
Google Web Toolkit Introduction - eXo Platform SEA
Google Web Toolkit Introduction - eXo Platform SEAGoogle Web Toolkit Introduction - eXo Platform SEA
Google Web Toolkit Introduction - eXo Platform SEAnerazz08
 
T 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By GwtT 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By Gwtsupertoy2015
 
Gwt session
Gwt sessionGwt session
Gwt sessionMans Jug
 
GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day DNG Consulting
 
Web polyglot programming
Web polyglot programmingWeb polyglot programming
Web polyglot programmingDmitry Buzdin
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTManuel Carrasco Moñino
 
Introduction to Google Web Toolkit
Introduction to Google Web ToolkitIntroduction to Google Web Toolkit
Introduction to Google Web ToolkitDidier Girard
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitIMC Institute
 
GWT Training - Session 1/3
GWT Training - Session 1/3GWT Training - Session 1/3
GWT Training - Session 1/3Faiz Bashir
 
Ext GWT - Overview and Implementation Case Study
Ext GWT - Overview and Implementation Case StudyExt GWT - Overview and Implementation Case Study
Ext GWT - Overview and Implementation Case StudyAvi Perez
 
GWT + Gears : The browser is the platform
GWT + Gears : The browser is the platformGWT + Gears : The browser is the platform
GWT + Gears : The browser is the platformDidier Girard
 

Semelhante a Javascript as a target language - GWT KickOff - Part 2/2 (20)

GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)
 
Gwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca TosiGwt kickoff - Alberto Mancini & Francesca Tosi
Gwt kickoff - Alberto Mancini & Francesca Tosi
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
Gwt Presentation1
Gwt Presentation1Gwt Presentation1
Gwt Presentation1
 
GWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO ToolsGWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO Tools
 
Google Web Toolkit Introduction - eXo Platform SEA
Google Web Toolkit Introduction - eXo Platform SEAGoogle Web Toolkit Introduction - eXo Platform SEA
Google Web Toolkit Introduction - eXo Platform SEA
 
T 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By GwtT 0230 Google Wave Powered By Gwt
T 0230 Google Wave Powered By Gwt
 
Gwt session
Gwt sessionGwt session
Gwt session
 
Gwt session
Gwt sessionGwt session
Gwt session
 
GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day GWT Introduction for Eclipse Day
GWT Introduction for Eclipse Day
 
The Java alternative to Javascript
The Java alternative to JavascriptThe Java alternative to Javascript
The Java alternative to Javascript
 
Web polyglot programming
Web polyglot programmingWeb polyglot programming
Web polyglot programming
 
GWT Basics
GWT BasicsGWT Basics
GWT Basics
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Introduction to Google Web Toolkit
Introduction to Google Web ToolkitIntroduction to Google Web Toolkit
Introduction to Google Web Toolkit
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
 
GWT Training - Session 1/3
GWT Training - Session 1/3GWT Training - Session 1/3
GWT Training - Session 1/3
 
Ext GWT - Overview and Implementation Case Study
Ext GWT - Overview and Implementation Case StudyExt GWT - Overview and Implementation Case Study
Ext GWT - Overview and Implementation Case Study
 
GWT + Gears : The browser is the platform
GWT + Gears : The browser is the platformGWT + Gears : The browser is the platform
GWT + Gears : The browser is the platform
 

Mais de JooinK

(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL ViewerJooinK
 
Power-up your mobile & web App with WebRTC
Power-up your mobile & web App with WebRTCPower-up your mobile & web App with WebRTC
Power-up your mobile & web App with WebRTCJooinK
 
Go native benchmark test su dispositivi x86: java, ndk, ipp e tbb
Go native  benchmark test su dispositivi x86: java, ndk, ipp e tbbGo native  benchmark test su dispositivi x86: java, ndk, ipp e tbb
Go native benchmark test su dispositivi x86: java, ndk, ipp e tbbJooinK
 
Javascript as a target language - GWT kickoff - part1/2
Javascript as a target language - GWT kickoff - part1/2Javascript as a target language - GWT kickoff - part1/2
Javascript as a target language - GWT kickoff - part1/2JooinK
 
WebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computationWebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computationJooinK
 
Augmented experience: Augmented Reality
Augmented experience: Augmented RealityAugmented experience: Augmented Reality
Augmented experience: Augmented RealityJooinK
 
JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK
 
Web&mobile - 4 ottobre 2012
Web&mobile  - 4 ottobre 2012Web&mobile  - 4 ottobre 2012
Web&mobile - 4 ottobre 2012JooinK
 
JooinK Presentation
JooinK PresentationJooinK Presentation
JooinK PresentationJooinK
 

Mais de JooinK (9)

(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer
 
Power-up your mobile & web App with WebRTC
Power-up your mobile & web App with WebRTCPower-up your mobile & web App with WebRTC
Power-up your mobile & web App with WebRTC
 
Go native benchmark test su dispositivi x86: java, ndk, ipp e tbb
Go native  benchmark test su dispositivi x86: java, ndk, ipp e tbbGo native  benchmark test su dispositivi x86: java, ndk, ipp e tbb
Go native benchmark test su dispositivi x86: java, ndk, ipp e tbb
 
Javascript as a target language - GWT kickoff - part1/2
Javascript as a target language - GWT kickoff - part1/2Javascript as a target language - GWT kickoff - part1/2
Javascript as a target language - GWT kickoff - part1/2
 
WebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computationWebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computation
 
Augmented experience: Augmented Reality
Augmented experience: Augmented RealityAugmented experience: Augmented Reality
Augmented experience: Augmented Reality
 
JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013
 
Web&mobile - 4 ottobre 2012
Web&mobile  - 4 ottobre 2012Web&mobile  - 4 ottobre 2012
Web&mobile - 4 ottobre 2012
 
JooinK Presentation
JooinK PresentationJooinK Presentation
JooinK Presentation
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Javascript as a target language - GWT KickOff - Part 2/2

  • 1. Js as a target language: GWT KickOff (Part 2/2) Alberto Mancini - alberto@jooink.com Francesca Tosi - francesca@jooink.com
  • 2. Alberto Mancini alberto@jooink.com http://github.com/jooink http://www.jooink.com http://jooink.blogspot.com
  • 3. Francesca Tosi francesca@jooink.com +FrancescaTosi @francescatosi http://github.com/jooink http://www.jooink.com http://jooink.blogspot.com
  • 4. GWT GWT is a toolkit to develop Ajax web application with Java. The programmer writes Java code and this code is translated into HTML and Javascript via the GWT compiler. The compiler creates browser specific HTML and JavaScript to support all the major browsers correctly.
  • 5. setup 1. java sdk: http://www.java.com/it/download/ (e.g 1.7) 2. eclipse: http://www.eclipse.org/downloads/ (e.g. EE) 3. GWT Eclipse Plugin: https://developers.google.com/eclipse/docs/getting_started 4. Create simple project 5. run ‘dev mode’ 6. open in browser http://127.0.0.1:8888/?get. condeserv=127.0.0.1:9997 (install browser plugin)
  • 6. GWT cont'd - Tools in the Toolkit + GWTc, compiler Java to Javascript + Emulated JRE + Web UI class library (Widgets) + Eclipse Plugin, SpeedTracer, Designer It's open source, completely free, and used by thousands of developers around the world (in Google AdWords,Orkut,Blogger,Groups)
  • 7. Toolkit != Framework Frameworks that may help https://github.com/ArcBees/GWTP model-view-presenter framework http://www.jboss.org/errai CDI, and JPA for GWT http://www.tessell.org/ app framework (on gwt-pectin)
  • 8. GWT cont'd - Developing & Running GWT provides two (3 actually) modes ● Development Mode: allows to debug the Java code of your application directly via the standard Java debugger. ● Web mode: the application is translated into HTML and Javascript code and can be deployed to a webserver. ● SuperDevMode
  • 9. GWT cont'd - Why ? Typed Language Well Known Programming Framework Optimize Browser Independence (quite, almost) + 'Native' through jsni Move Objects between client and server
  • 10. GWT cont'd - History ● GWT 1.0 (2006) ● GWT 1.3 (2007) First Open Source Release, OSX support ● GWT 1.4 (2007) JUnit and ImageBundle ● GWT 1.5 (2008) Java 1.5 support, Overlay Types, DOM API, CSS Themes, Linkers ● GWT 1.6 (2009) EventHandlers, EMMA Support, WAR support, Parallelized Builds ● GWT 1.7 (2009) Newer browser support, IE8, GPE and AppEngine ● GWT 2.0 (2009) DevMode, DraftCompile, UIBinder, LayoutPanel, CodeSplitter, ClientBundle, CssResource ● GWT 2.1 (2010) RequestFactory, Editor Framework, Validation, MVP, Cell Widgets ● GWT 2.2 (2011) GWT Designer, HTML5 support ● GWT 2.3 (2011) Better AppEngine integration ● GWT 2.4 (2011) Maven and RequestFactory enhancements ● GWT 2.5 (2012) SuperDevMode, Elemental, UiRenderers, FragmentMerging, ClosureCompiler
  • 11. GWT cont'd - History ● GWT 2.5.1 (2013) - bugfixes and optimizations ● GWT 2.6.0 (2014) - java 7 - IE10 - Internet Explorer cleanup: IE6/7 ● GWT 2.6.1 (2014) - working on Super Dev Mode Annual Vaadin “The Future of GWT Report” https://vaadin.com/gwt/report-2013 What’s going on. SuperDevMode Java8 JsInterop GSS
  • 12. GWT cont'd - Open Source Project The GWT Steering committee was founded in 2012 to help the GWT project become an even bigger success as an open source project. ● Ray Cromwell, Google ● Artur Signell, Vaadin ● Colin Alworth, Sencha ● Mike Brock, RedHat ● Thomas Broyer ● Stephen Haberman, Bizo ● Daniel Kurka, Google ● Christian Goudreau, Arcbees ● Konstantin Solomatov, Jetbrains
  • 13. Anatomy Module html file Module xml file translatable directories
  • 14. Modules Individual units of GWT configuration are called modules. A module bundles together all the configuration settings that a GWT project needs: ● inherited modules ● an entry point application class name; these are optional, although any module referred to in HTML must have at least one entry-point class specified ● source path entries ● public path entries ● deferred binding rules, including property providers and class generators
  • 15. Deferred Binding Deferred Binding is a feature of the GWT compiler that works by generating many versions of code at compile time, only one of which needs to be loaded by a particular client during bootstrapping at runtime. Each version is generated on a per browser basis, along with any other axis that your application defines or uses. RPC Calls Widgets tuned for specific browsers Internationalization
  • 16. Deferred Binding cont'd Deferred binding has several benefits: ● Reduces the size of the generated JavaScript code that a client will need to download by only including the code needed to run a particular browser/locale instance (used by the Internationalization module) ● Saves development time by automatically generating code to implement an interface or create a proxy class (used by the GWT RPC module) ● Since the implementations are pre-bound at compile time, there is no run-time penalty to look up an implementation in a data structure as with dynamic binding or using virtual functions.
  • 17. conditional compilation - replacement A type is replaced with another depending on a set of configurable rules. IType = GWT.create(TypeImpl.class); <replace-with class="...TypeImplFirefox"> <when-type-is class="...TypeImpl" /> <when-property-is name="user.agent" value="gecko"/> </replace-with>
  • 18. properties & property providers <property-provider name="property_name"> Define a JavaScript fragment that will return the value for the named property at runtime. //mobilewebapp sample <define-property name="formfactor" values="desktop,tablet,mobile"/> <collapse-property name="formfactor" values="*"/> <property-provider name="formfactor"> <![CDATA[ .... return (size < 6) ? "mobile" : "tablet"; ... return "desktop"; ]]>
  • 19. Generators Generators are classes that are invoked by the GWT compiler to generate a Java implementation of a class during compilation <generate-with class="...XYGenerator"> <when-type-assignable class="...XYType" /> </generate-with> </module> XYType=GWT.create(...); (e.g. RPC, UiBinder)
  • 20. Generator Class Defining a subclass of the Generator class is like defining a plug-in to the GWT compiler. public class XYGenerator extends Generator { public String generate(TreeLogger logger, GeneratorContext ctx, String requestedClass) throws UnableToCompleteException { ... } }
  • 21. emulated JRE GWT includes a library that emulates a subset of the Java runtime library. http://www.gwtproject. org/doc/latest/RefJreEmulation.html InputStream Threads ?
  • 22. <super-source> The <super-source> tag instructs the compiler to "re-root" a source path. This is useful for cases where you want to re-use an existing Java API for a GWT project, but the original source is not available or not translatable. A common reason for this is to emulate part of the JRE not implemented by GWT.
  • 23. JSNI GWT borrows from the Java Native Interface (JNI) concept to implement JavaScript Native Interface (JSNI). Writing JSNI methods is a powerful technique, but should be used sparingly because writing bulletproof JavaScript code is notoriously tricky. Needed for JSO (Javascript Overlay Types)
  • 24. JSNI cont'd public static native void alert(String msg) /*-{ $wnd.alert(msg); }-*/; $wnd: the root browser window GWT widgets are being rendered to $entry(..): method that makes code reentry safe. http://www.lustforge.com/2012/11/11/gwt-jsni-variables-an-exhaustive-list/ http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html
  • 25. Widgets UiComponents http://www.gwtproject.org/doc/latest/RefWidgetGallery.html 2.0+ LayoutPanels http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html#LayoutPanels from the Jul 2013 - GWT Meetup What are some of pain points or decisions bad in hindsight? ... ● Bad out of box UI ... SmartGWT, GXT
  • 26. UiBinder ● The UiBinder is a framework designed to separate Functionality and View of User Interface. ● The UiBinder framework allows developers to build gwt applications as HTML pages with GWT widgets configured throughout them. ● The UiBinder framework makes easier collaboration with UI designers who are more comfortable with XML, HTML and CSS than Java source code ● The UIBinder provides a declarative way of defining (parts of the) User Interface. ● The UIBinder seperates the programmic logic from UI. ● The UIBinder is similar to what JSP is to Servlets.
  • 27. UiBinder cont'd DSL (xml) to lay-out (declaratively) widgets no loops, no conditionals, no if statements UiBinder allows you to lay out your user interface. (offers direct support for internationalization)
  • 28. UiBinder - syntax <!-- HelloWidgetWorld.ui.xml --> <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'> <g:HTMLPanel> Hello, <g:ListBox ui:field='listBox' visibleItemCount='1'/>. </g:HTMLPanel> </ui:UiBinder> xmlns:g='urn:import:..' binds package to namespace ui:field gives name to the widget Every one of the widget's methods that follow JavaBean-style conventions for setting a property can be used: visibleItemCount transl. as setVisibleItemCount(...)
  • 29. UiBinder - syntax public class HelloWidgetWorld extends Composite { interface MyUiBinder extends UiBinder<Widget, HelloWidgetWorld> {} private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); @UiField ListBox listBox; public HelloWidgetWorld(String... names) { // sets listBox initWidget(uiBinder.createAndBindUi(this)); for (String name : names) { listBox.addItem(name); } } }
  • 30. UiBinder - misc uses the default (with no args) constructor @UiField(provided=true) [or read the docs] can associate handlers @UiHandler("button") void handleClick(ClickEvent e) { ..... } can inject any type (inst'd through GWT.create) <ui:with field='res' type='...'/>
  • 31. UiBinder - ui:style With the <ui:style> element, you can define the CSS for your UI right where you need it. <ui:style> .example { background-color: red } </ui:style> ... <g:HTML addStyleNames="{style.red}"/> ...
  • 32. UiBinder - ui:style <ui:style src="MyUi.css" /> <ui:style field='oStyle' src="MyUiOStyle.css"> <ui:style type='com.my.app.MyFoo.MyStyle'> @UiField MyStyle style; (CssResource oStyle)
  • 33. CssResource interface MyStyle extends CssResource { String enabled(); String disabled(); } @UiField MyStyle style; style.enabled() (class name) http://www.gwtproject.org/javadoc/latest/com/google/gwt/resources/client/CssResource.html
  • 34. ClientBundle public interface Resources extends ClientBundle { @Source("Style.css") Style style(); @Source("Logo.jpg") ImageResource logo(); public interface Style extends CssResource { String mainBlock(); String nameSpan(); Sprite userPictureSprite(); } }
  • 36. Thanks Alberto Mancini alberto@jooink.com Francesca Tosi francesca@jooink.com