SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Wednesday, March 17, 2010
Google Web Toolkit



Wednesday, March 17, 2010
Google Web Toolkit
                                   GWT




Wednesday, March 17, 2010
Úvod




Wednesday, March 17, 2010
Úvod
                   • GWT je javascriptový framework




Wednesday, March 17, 2010
Úvod
                   • GWT je javascriptový framework
                   • Vývoj v JAVE (kompilátor preloží do JS)




Wednesday, March 17, 2010
Úvod
                   • GWT je javascriptový framework
                   • Vývoj v JAVE (kompilátor preloží do JS)
                    • silné IDE - refaktor, code completion



Wednesday, March 17, 2010
Úvod
                   • GWT je javascriptový framework
                   • Vývoj v JAVE (kompilátor preloží do JS)
                    • silné IDE - refaktor, code completion
                    • unit testovanie, moznosť TDD


Wednesday, March 17, 2010
Úvod
                   • GWT je javascriptový framework
                   • Vývoj v JAVE (kompilátor preloží do JS)
                    • silné IDE - refaktor, code completion
                    • unit testovanie, moznosť TDD
                    • integrácia s backendami (Spring,
                            Hibernate, JSF a ďalšie)


Wednesday, March 17, 2010
Úvod
                   • GWT je javascriptový framework
                   • Vývoj v JAVE (kompilátor preloží do JS)
                    • silné IDE - refaktor, code completion
                    • unit testovanie, moznosť TDD
                    • integrácia s backendami (Spring,
                            Hibernate, JSF a ďalšie)


Wednesday, March 17, 2010
Úvod




Wednesday, March 17, 2010
Úvod

                            • debug kódu v prehliadači




Wednesday, March 17, 2010
Úvod

                            • debug kódu v prehliadači
                            • kompatibilita



Wednesday, March 17, 2010
Úvod

                            • debug kódu v prehliadači
                            • kompatibilita
                             • IE 6+, FF 1.x+, Opera 8.5+, Safari 2.0.x


Wednesday, March 17, 2010
Hello world!
                        public class HelloApp implements EntryPoint {
                                public void onModuleLoad() {
                                      Button b = new Button("Click me", new ClickListener() {
                                             public void onClick(Widget sender) {
                                               Window.alert("Hello world!");
                                             }
                                      }
                                      RootPanel.get().add(b);
                                }
                        }




Wednesday, March 17, 2010
Wednesday, March 17, 2010
Widgets
Wednesday, March 17, 2010
Panels
Wednesday, March 17, 2010
Project Layout
                   •        module base

                   •        .client - kód ktorý sa
                            kompiluje do JS

                   •        .server - java kód ktorý
                            nebude kompilovaný do
                            JS (ale bude pristupný
                            iba na serveri)

                   •        .public - resources



Wednesday, March 17, 2010
Module
                   • XML súbor MyApp.gwt.xml
                   • source
                   • super source
                   • deferred binding
                   • inherited modules
                   • entry point
Wednesday, March 17, 2010
Module XML
               <module>
                 <inherits name="com.google.gwt.user.User" />
                 <inherits name="com.google.gwt.user.theme.standard.Standard" />

                   <entry-point class="com.your.application.client.HelloApp" />

                   <script src=”someScript_inside_PublicFolder.js” />
                   <stylesheet src=”publicFolderRelativeURL_OR_HttpFullPath.css”/>

                 <source path=”shared” />
                 <super-source path=”jre” />
               <module>




Wednesday, March 17, 2010
Module - source
                   • <source src=”client” />
                   • com.app.Module.gwt.xml
                    • com.app.client.* - kód ktorý sa bude
                              kompilovať
                            • com.app.other* alebo com.other.*- na
                              tento kód gwt neuvidí a nebude sa
                              kompilovať do JS


Wednesday, March 17, 2010
Module - super-source

                   • <super-source src=”jre” />
                   • com.app.Module.gwt.xml
                    • com.app.jre.java.util.UUID.java -
                            kompilátor to uvidí ako
                            java.util.UUID.java



Wednesday, March 17, 2010
Module - deferred
                   <!-- Fall through to this rule is the browser isn't IE or Mozilla -->
                 <replace-with class="com.google.gwt.user.client.ui.impl.PopupImpl">
                   <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl"/>
                 </replace-with>

                 <!-- Mozilla needs a different implementation due to issue #410 -->
                 <replace-with class="com.google.gwt.user.client.ui.impl.PopupImplMozilla">
                   <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl" />
                   <any>
                     <when-property-is name="user.agent" value="gecko"/>
                     <when-property-is name="user.agent" value="gecko1_8" />
                   </any>
                 </replace-with>




Wednesday, March 17, 2010
Module - deferred
                        public class HelloApp implements EntryPoint {
                                public void onModuleLoad() {
                                      PopupImpl impl = GWT.create(PopupImpl.class);
                                      impl.callSomeMethod();
                                }
                        }




Wednesday, March 17, 2010
Index.html
               <html>
                 <head>
                    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
                    <title>Web Application Starter Project</title>

                        <script type="text/javascript" language="javascript"
                      src="com.your.application.client.HelloApp.nocache.js"></script>
                   </head>
                   <body>
                      <h1>GWT content</h1>
                        <div id=”gwt-main-container”></div>
                    <div id=”gwt-sub-container”></div>
                 </body>
               </html>



Wednesday, March 17, 2010
Hello world!
                        public class HelloApp implements EntryPoint {
                                public void onModuleLoad() {
                                      Button b = new Button("Click me", new ClickListener() {
                                             public void onClick(Widget sender) {
                                               Window.alert("Hello world!");
                                             }
                                      }
                                      RootPanel.get(“gwt-main-container”).add(b);
                                }
                        }




Wednesday, March 17, 2010
Index.html
                   <body>
                     <h1>GWT content</h1>
                        <div id=”gwt-main-container”>
                            <button
                              type=”button”
                              tabindex=”0”
                            class=”gwt-Button”>Click me</button>
                      </div>
                      <div id=”gwt-sub-container”></di
                   </body>




Wednesday, March 17, 2010
Debug




Wednesday, March 17, 2010
Request Response




Wednesday, March 17, 2010
AJAX




                   •        AJAX (Asynchronous JavaScript and XML) mení obsah
                            stránky bez nutnosti znovunačítania

                   •        RIA (desktop-like Rich Internet Application) aka WEB 2.0

Wednesday, March 17, 2010
AJAX v podani GWT




Wednesday, March 17, 2010
AJAX v podani GWT
               / some code flow
                /

               / GWT.create(YourService.class);
                /
               YourService.Util.getInstance().method(param, new AsyncCallback() {
                 public void onFailure(Throwable e) {
                    Window.alertError(“error occured”);
                 }

                     public void onSuccess(Object result) {
                       / and more logic continues
                        /
                       / process the result
                        /
                     }
               });




Wednesday, March 17, 2010
Client Bundles

                   • obrázky - multi-obrázok (jeden request)
                   • minimalizuje chyby medzi filename-om a
                            konštantou

                   • rozširiteľný design pre nové resource typy


Wednesday, March 17, 2010
Client Bundles
               <inherits name="com.google.gwt.resources.Resources" />

               public interface MyResources extends ClientBundle {
                 public static final MyResources INSTANCE = GWT.create
                 (MyResources.class);

                 @Source("my.css")
                 public CssResource css();

                 @Source("config.xml")
                 public TextResource initialConfiguration();

                 @Source("manual.pdf")
                 public DataResource ownersManual();




Wednesday, March 17, 2010
Client Bundles
               / Inject the contents of the CSS file
                /
               MyResources.INSTANCE.css().ensureInjected();

               / Display the manual file in an iframe
                /
               new Frame(MyResources.INSTANCE.ownersManual().getURL());




Wednesday, March 17, 2010
Client Bundles
               @Source("logo.png")
               ImageResource logo();

               @Source("arrow.png")
               @ImageOptions(flipRtl = true)
               ImageResource pointer();

               @Source("a.txt")
               TextResource synchronous();

               @Source("b.txt")
               ExternalTextResource asynchronous();




Wednesday, March 17, 2010
Client Bundles
               / Using a TextResource
                /
               myTextArea.setInnerText(Resources.INSTANCE.synchronous().getText());

               / Using an ExternalTextResource
                /
               Resources.INSTANCE.asynchronous().getText(new
               ResourceCallback<TextResource>() {
                 public void onError(ResourceException e) { ... }
                 public void onSuccess(TextResource r) {
                   myTextArea.setInnerText(r.getText());
                }
               });




Wednesday, March 17, 2010
Vlastne komponenty

                   • extends Widget
                    • setElement()
                   • extends Composite
                    • initWidget()
                   • extends Button, Panel, ....

Wednesday, March 17, 2010
JSNI

                   • JavaScript Native Interface
                   • ľahko kombinovateľný JavaScript kód do
                            GWT
                   • volanie metód z GWT v JS
                   • volanie metód z JS v GWT

Wednesday, March 17, 2010
JSNI Syntax

                   • /*-{ JavaScript code here }-*/;
                   • native void nativeJsCall()/*-{alert(“JS”);}-*/;
                   • $wnd - pointer na window (ale preco?)


Wednesday, March 17, 2010
JSNI - JS call do GWT

                   • [instance-expr.]@class-name::method-name
                            (param-signature)(arguments)


                   • [instance-expr.]@class-name::field-name


Wednesday, March 17, 2010
JSNI - JS call do GWT
               [instance-expr.]@class-name::method-name(param-signature)(arguments)
               / method calls
                /
               this.@com.example.client.MyClass::setStringValue(Ljava/lang/String;)(s);

               x.@com.example.client.MyClass::setStringValue(Ljava/lang/String;)(s);

               @com.example.client.MyClass::setStaticValue(Ljava/lang/String;)(s);

               / fields
                /
               var val = this.@com.example.client.MyClass::valueStringFiled

               x.@com.example.client.MyClass::valueStringField = val + " and stuff";




Wednesday, March 17, 2010
JSNI - JS call do GWT
                Type Signature   Java Type   long f (int n, String s, int[] arr);
                         Z         boolean                    =
                         B           byte    (ILjava/lang/String;[I)J
                         C           char
                         S          short
                         I            int
                         J           long
                         F           float
                         D         double
                     L class ;       class
                      [ type        type[]

Wednesday, March 17, 2010
JavaScript overlay types

                   • JS objekt ako Java objekt
                   • protected konštruktor - bez arg
                   • mžnosť písť natívne aj nenatívne metódy
                   • nesmie obsahovať fieldy

Wednesday, March 17, 2010
JavaScript overlay types
               var jsonData = [
                 { "FirstName" :   "Jimmy", "LastName" : "Webber" },
                 { "FirstName" :   "Alan",  "LastName" : "Dayal" },
                 { "FirstName" :   "Keanu", "LastName" : "Spoon" },
                 { "FirstName" :   "Emily", "LastName" : "Rudnick" }
               ];




Wednesday, March 17, 2010
JavaScript overlay types
               class Customer extends JavaScriptObject {
                 / Overlay types always have protected, zero-arg ctors
                  /
                 protected Customer() { }

                 / Typically, methods on overlay types are JSNI
                  /
                   public final native String getFirstName() /*-{return this.FirstName; }-*/;
                   public final native String getLastName()  /*-{return this.LastName; }-*/;

                   / Note, though, that methods aren't required to be JSNI
                    /
                   public final String getFullName() {
                     return getFirstName() + " " + getLastName();
                   }
               }




Wednesday, March 17, 2010
JavaScript overlay types
               class MyModuleEntryPoint implements EntryPoint {
                 public void onModuleLoad() {
                   JsArray<Customer> cs = getCustomers();
                   for (int i = 0, n = cs.length(); i < n; ++i) {
                     Window.alert("Hello, " + cs.get(i).getFullName());
                 }
                }

                 / Return the whole JSON array, as is
                  /
                 private final native JsArray<Customer> getCustomers() /*-{
                   return $wnd.jsonData;
                 }-*/;
               }




Wednesday, March 17, 2010
JavaScript overlay types
               function $onModuleLoad(){
                 var cs, i, n;
                 cs = $wnd.jsonData;
                 for (i = 0, n = cs.length; i < n; ++i) {
                   $wnd.alert('Hello, ' + (cs[i].FirstName + ' ' + cs[i].LastName));
                }
               }

               //---------------------------------------------------------------------

               function B(){var a,b,c;a=$wnd.jsonData;for(b=0,c=a.length;b<c;++b)
               {$wnd.alert(l+(a[b].FirstName+m+a[b].LastName))}}




Wednesday, March 17, 2010
Wednesday, March 17, 2010
Wednesday, March 17, 2010
Dovidenia
Wednesday, March 17, 2010

Weitere ähnliche Inhalte

Was ist angesagt? (7)

What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Practical introduction to dependency injection
Practical introduction to dependency injectionPractical introduction to dependency injection
Practical introduction to dependency injection
 
Groovy Tutorial
Groovy TutorialGroovy Tutorial
Groovy Tutorial
 
Gentle Intro to Drupal Code
Gentle Intro to Drupal CodeGentle Intro to Drupal Code
Gentle Intro to Drupal Code
 
Ten Minutes To Tellurium
Ten Minutes To TelluriumTen Minutes To Tellurium
Ten Minutes To Tellurium
 
Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4
 
State of Puppet - Puppet Camp Barcelona 2013
State of Puppet - Puppet Camp Barcelona 2013State of Puppet - Puppet Camp Barcelona 2013
State of Puppet - Puppet Camp Barcelona 2013
 

Andere mochten auch (9)

Úvod do OOP
Úvod do OOPÚvod do OOP
Úvod do OOP
 
Úvod do rails
Úvod do railsÚvod do rails
Úvod do rails
 
Ondra Kučera: Otevřený web a jeho současný stav
Ondra Kučera: Otevřený web a jeho současný stavOndra Kučera: Otevřený web a jeho současný stav
Ondra Kučera: Otevřený web a jeho současný stav
 
CZNIC: Správa internetu, routing a IPv6
CZNIC: Správa internetu, routing a IPv6CZNIC: Správa internetu, routing a IPv6
CZNIC: Správa internetu, routing a IPv6
 
Google App Engine - exploiting limitations
Google App Engine - exploiting limitationsGoogle App Engine - exploiting limitations
Google App Engine - exploiting limitations
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Gwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORMGwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORM
 
Django
DjangoDjango
Django
 
Začínáme iOS vývoj
Začínáme iOS vývojZačínáme iOS vývoj
Začínáme iOS vývoj
 

Ähnlich wie Základy GWT

Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010
Guillaume Laforge
 
JBoss @ CVUT FIT April 2013
JBoss @ CVUT FIT April 2013JBoss @ CVUT FIT April 2013
JBoss @ CVUT FIT April 2013
Vaclav Tunka
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
Ran Mizrahi
 
JBoss @ Slovakia, UNIZA & TUKE Universities November 2013
JBoss @ Slovakia, UNIZA & TUKE Universities November 2013JBoss @ Slovakia, UNIZA & TUKE Universities November 2013
JBoss @ Slovakia, UNIZA & TUKE Universities November 2013
Vaclav Tunka
 
Building Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web StackBuilding Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web Stack
Jeremy Grelle
 

Ähnlich wie Základy GWT (20)

GWT♥HTML5
GWT♥HTML5GWT♥HTML5
GWT♥HTML5
 
Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2
 
JBoss @ CVUT FIT April 2013
JBoss @ CVUT FIT April 2013JBoss @ CVUT FIT April 2013
JBoss @ CVUT FIT April 2013
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
JBoss @ Slovakia, UNIZA & TUKE Universities November 2013
JBoss @ Slovakia, UNIZA & TUKE Universities November 2013JBoss @ Slovakia, UNIZA & TUKE Universities November 2013
JBoss @ Slovakia, UNIZA & TUKE Universities November 2013
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Javascript Frameworks Comparison
Javascript Frameworks ComparisonJavascript Frameworks Comparison
Javascript Frameworks Comparison
 
What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy Edges
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
What's New in GWT 2.2
What's New in GWT 2.2What's New in GWT 2.2
What's New in GWT 2.2
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
 
Javascript Apps at Build Artifacts
Javascript Apps at Build ArtifactsJavascript Apps at Build Artifacts
Javascript Apps at Build Artifacts
 
Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
Building Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web StackBuilding Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web Stack
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Základy GWT

  • 3. Google Web Toolkit GWT Wednesday, March 17, 2010
  • 5. Úvod • GWT je javascriptový framework Wednesday, March 17, 2010
  • 6. Úvod • GWT je javascriptový framework • Vývoj v JAVE (kompilátor preloží do JS) Wednesday, March 17, 2010
  • 7. Úvod • GWT je javascriptový framework • Vývoj v JAVE (kompilátor preloží do JS) • silné IDE - refaktor, code completion Wednesday, March 17, 2010
  • 8. Úvod • GWT je javascriptový framework • Vývoj v JAVE (kompilátor preloží do JS) • silné IDE - refaktor, code completion • unit testovanie, moznosť TDD Wednesday, March 17, 2010
  • 9. Úvod • GWT je javascriptový framework • Vývoj v JAVE (kompilátor preloží do JS) • silné IDE - refaktor, code completion • unit testovanie, moznosť TDD • integrácia s backendami (Spring, Hibernate, JSF a ďalšie) Wednesday, March 17, 2010
  • 10. Úvod • GWT je javascriptový framework • Vývoj v JAVE (kompilátor preloží do JS) • silné IDE - refaktor, code completion • unit testovanie, moznosť TDD • integrácia s backendami (Spring, Hibernate, JSF a ďalšie) Wednesday, March 17, 2010
  • 12. Úvod • debug kódu v prehliadači Wednesday, March 17, 2010
  • 13. Úvod • debug kódu v prehliadači • kompatibilita Wednesday, March 17, 2010
  • 14. Úvod • debug kódu v prehliadači • kompatibilita • IE 6+, FF 1.x+, Opera 8.5+, Safari 2.0.x Wednesday, March 17, 2010
  • 15. Hello world! public class HelloApp implements EntryPoint { public void onModuleLoad() { Button b = new Button("Click me", new ClickListener() { public void onClick(Widget sender) { Window.alert("Hello world!"); } } RootPanel.get().add(b); } } Wednesday, March 17, 2010
  • 19. Project Layout • module base • .client - kód ktorý sa kompiluje do JS • .server - java kód ktorý nebude kompilovaný do JS (ale bude pristupný iba na serveri) • .public - resources Wednesday, March 17, 2010
  • 20. Module • XML súbor MyApp.gwt.xml • source • super source • deferred binding • inherited modules • entry point Wednesday, March 17, 2010
  • 21. Module XML <module> <inherits name="com.google.gwt.user.User" /> <inherits name="com.google.gwt.user.theme.standard.Standard" /> <entry-point class="com.your.application.client.HelloApp" /> <script src=”someScript_inside_PublicFolder.js” /> <stylesheet src=”publicFolderRelativeURL_OR_HttpFullPath.css”/> <source path=”shared” /> <super-source path=”jre” /> <module> Wednesday, March 17, 2010
  • 22. Module - source • <source src=”client” /> • com.app.Module.gwt.xml • com.app.client.* - kód ktorý sa bude kompilovať • com.app.other* alebo com.other.*- na tento kód gwt neuvidí a nebude sa kompilovať do JS Wednesday, March 17, 2010
  • 23. Module - super-source • <super-source src=”jre” /> • com.app.Module.gwt.xml • com.app.jre.java.util.UUID.java - kompilátor to uvidí ako java.util.UUID.java Wednesday, March 17, 2010
  • 24. Module - deferred <!-- Fall through to this rule is the browser isn't IE or Mozilla -->   <replace-with class="com.google.gwt.user.client.ui.impl.PopupImpl">     <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl"/>   </replace-with>   <!-- Mozilla needs a different implementation due to issue #410 -->   <replace-with class="com.google.gwt.user.client.ui.impl.PopupImplMozilla">     <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl" />     <any>       <when-property-is name="user.agent" value="gecko"/>       <when-property-is name="user.agent" value="gecko1_8" />     </any>   </replace-with> Wednesday, March 17, 2010
  • 25. Module - deferred public class HelloApp implements EntryPoint { public void onModuleLoad() { PopupImpl impl = GWT.create(PopupImpl.class); impl.callSomeMethod(); } } Wednesday, March 17, 2010
  • 26. Index.html <html> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> <title>Web Application Starter Project</title> <script type="text/javascript" language="javascript" src="com.your.application.client.HelloApp.nocache.js"></script> </head> <body> <h1>GWT content</h1> <div id=”gwt-main-container”></div> <div id=”gwt-sub-container”></div> </body> </html> Wednesday, March 17, 2010
  • 27. Hello world! public class HelloApp implements EntryPoint { public void onModuleLoad() { Button b = new Button("Click me", new ClickListener() { public void onClick(Widget sender) { Window.alert("Hello world!"); } } RootPanel.get(“gwt-main-container”).add(b); } } Wednesday, March 17, 2010
  • 28. Index.html <body> <h1>GWT content</h1> <div id=”gwt-main-container”> <button type=”button” tabindex=”0” class=”gwt-Button”>Click me</button> </div> <div id=”gwt-sub-container”></di </body> Wednesday, March 17, 2010
  • 31. AJAX • AJAX (Asynchronous JavaScript and XML) mení obsah stránky bez nutnosti znovunačítania • RIA (desktop-like Rich Internet Application) aka WEB 2.0 Wednesday, March 17, 2010
  • 32. AJAX v podani GWT Wednesday, March 17, 2010
  • 33. AJAX v podani GWT / some code flow / / GWT.create(YourService.class); / YourService.Util.getInstance().method(param, new AsyncCallback() { public void onFailure(Throwable e) { Window.alertError(“error occured”); } public void onSuccess(Object result) { / and more logic continues / / process the result / } }); Wednesday, March 17, 2010
  • 34. Client Bundles • obrázky - multi-obrázok (jeden request) • minimalizuje chyby medzi filename-om a konštantou • rozširiteľný design pre nové resource typy Wednesday, March 17, 2010
  • 35. Client Bundles <inherits name="com.google.gwt.resources.Resources" /> public interface MyResources extends ClientBundle { public static final MyResources INSTANCE = GWT.create (MyResources.class);   @Source("my.css")   public CssResource css();   @Source("config.xml")   public TextResource initialConfiguration();   @Source("manual.pdf")   public DataResource ownersManual(); Wednesday, March 17, 2010
  • 36. Client Bundles / Inject the contents of the CSS file / MyResources.INSTANCE.css().ensureInjected(); / Display the manual file in an iframe / new Frame(MyResources.INSTANCE.ownersManual().getURL()); Wednesday, March 17, 2010
  • 37. Client Bundles @Source("logo.png") ImageResource logo(); @Source("arrow.png") @ImageOptions(flipRtl = true) ImageResource pointer(); @Source("a.txt") TextResource synchronous(); @Source("b.txt") ExternalTextResource asynchronous(); Wednesday, March 17, 2010
  • 38. Client Bundles / Using a TextResource / myTextArea.setInnerText(Resources.INSTANCE.synchronous().getText()); / Using an ExternalTextResource / Resources.INSTANCE.asynchronous().getText(new ResourceCallback<TextResource>() {   public void onError(ResourceException e) { ... }   public void onSuccess(TextResource r) {     myTextArea.setInnerText(r.getText());  } }); Wednesday, March 17, 2010
  • 39. Vlastne komponenty • extends Widget • setElement() • extends Composite • initWidget() • extends Button, Panel, .... Wednesday, March 17, 2010
  • 40. JSNI • JavaScript Native Interface • ľahko kombinovateľný JavaScript kód do GWT • volanie metód z GWT v JS • volanie metód z JS v GWT Wednesday, March 17, 2010
  • 41. JSNI Syntax • /*-{ JavaScript code here }-*/; • native void nativeJsCall()/*-{alert(“JS”);}-*/; • $wnd - pointer na window (ale preco?) Wednesday, March 17, 2010
  • 42. JSNI - JS call do GWT • [instance-expr.]@class-name::method-name (param-signature)(arguments) • [instance-expr.]@class-name::field-name Wednesday, March 17, 2010
  • 43. JSNI - JS call do GWT [instance-expr.]@class-name::method-name(param-signature)(arguments) / method calls / this.@com.example.client.MyClass::setStringValue(Ljava/lang/String;)(s); x.@com.example.client.MyClass::setStringValue(Ljava/lang/String;)(s); @com.example.client.MyClass::setStaticValue(Ljava/lang/String;)(s); / fields / var val = this.@com.example.client.MyClass::valueStringFiled x.@com.example.client.MyClass::valueStringField = val + " and stuff"; Wednesday, March 17, 2010
  • 44. JSNI - JS call do GWT Type Signature Java Type long f (int n, String s, int[] arr); Z boolean = B byte (ILjava/lang/String;[I)J C char S short I int J long F float D double L class ; class [ type type[] Wednesday, March 17, 2010
  • 45. JavaScript overlay types • JS objekt ako Java objekt • protected konštruktor - bez arg • mžnosť písť natívne aj nenatívne metódy • nesmie obsahovať fieldy Wednesday, March 17, 2010
  • 46. JavaScript overlay types var jsonData = [   { "FirstName" : "Jimmy", "LastName" : "Webber" },   { "FirstName" : "Alan",  "LastName" : "Dayal" },   { "FirstName" : "Keanu", "LastName" : "Spoon" },   { "FirstName" : "Emily", "LastName" : "Rudnick" } ]; Wednesday, March 17, 2010
  • 47. JavaScript overlay types class Customer extends JavaScriptObject {   / Overlay types always have protected, zero-arg ctors /   protected Customer() { }   / Typically, methods on overlay types are JSNI / public final native String getFirstName() /*-{return this.FirstName; }-*/; public final native String getLastName()  /*-{return this.LastName; }-*/; / Note, though, that methods aren't required to be JSNI / public final String getFullName() {   return getFirstName() + " " + getLastName(); } } Wednesday, March 17, 2010
  • 48. JavaScript overlay types class MyModuleEntryPoint implements EntryPoint {   public void onModuleLoad() {     JsArray<Customer> cs = getCustomers();     for (int i = 0, n = cs.length(); i < n; ++i) {       Window.alert("Hello, " + cs.get(i).getFullName());   }  }   / Return the whole JSON array, as is /   private final native JsArray<Customer> getCustomers() /*-{     return $wnd.jsonData;   }-*/; } Wednesday, March 17, 2010
  • 49. JavaScript overlay types function $onModuleLoad(){   var cs, i, n;   cs = $wnd.jsonData;   for (i = 0, n = cs.length; i < n; ++i) {     $wnd.alert('Hello, ' + (cs[i].FirstName + ' ' + cs[i].LastName));  } } //--------------------------------------------------------------------- function B(){var a,b,c;a=$wnd.jsonData;for(b=0,c=a.length;b<c;++b) {$wnd.alert(l+(a[b].FirstName+m+a[b].LastName))}} Wednesday, March 17, 2010