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?

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 6Gal Marder
 
Practical introduction to dependency injection
Practical introduction to dependency injectionPractical introduction to dependency injection
Practical introduction to dependency injectionTamas Rev
 
Groovy Tutorial
Groovy TutorialGroovy Tutorial
Groovy TutorialPaul King
 
Gentle Intro to Drupal Code
Gentle Intro to Drupal CodeGentle Intro to Drupal Code
Gentle Intro to Drupal CodeAddison Berry
 
Ten Minutes To Tellurium
Ten Minutes To TelluriumTen Minutes To Tellurium
Ten Minutes To TelluriumJohn.Jian.Fang
 
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 BCA4John Ballinger
 
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 2013Puppet
 

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

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ý stavTomáš Holas
 
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 IPv6Tomáš Holas
 
Google App Engine - exploiting limitations
Google App Engine - exploiting limitationsGoogle App Engine - exploiting limitations
Google App Engine - exploiting limitationsTomáš Holas
 
Gwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORMGwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORMTomáš Holas
 

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 2010Guillaume Laforge
 
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 BackboneDeepu S Nath
 
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/2JooinK
 
JBoss @ CVUT FIT April 2013
JBoss @ CVUT FIT April 2013JBoss @ CVUT FIT April 2013
JBoss @ CVUT FIT April 2013Vaclav Tunka
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan 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 2013Vaclav Tunka
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby ConferenceJohn Woodell
 
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 YoonJesang Yoon
 
Javascript Frameworks Comparison
Javascript Frameworks ComparisonJavascript Frameworks Comparison
Javascript Frameworks ComparisonDeepu S Nath
 
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.0Bruno Borges
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy EdgesJimmy Ray
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
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.WO Community
 
Javascript Apps at Build Artifacts
Javascript Apps at Build ArtifactsJavascript Apps at Build Artifacts
Javascript Apps at Build ArtifactsClay Smith
 
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 CODIos890
 
"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 NelsonGWTcon
 
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 StackJeremy 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

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

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