SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
What’s new in DWR v3


Joe Walker
DWR Lead Developer
SitePen UK
Recap
                                                  Since we last talked ...
                                                    Named Parameters
                                                        Binary Files
                                                JavaScript Extending Java
                                                    Better Reverse Ajax
                                               Data Sync: Dojo Data Store
                                               JSON / JSONP / JSON-RPC
                                            Varargs and Overloaded Methods
                                                        What’s Next


© SitePen, Inc. 2008. All Rights Reserved
Recap



© SitePen, Inc. 2008. All Rights Reserved
© SitePen, Inc. 2008. All Rights Reserved
Marshalling Types

        Primitive types, and their Object counterparts
                 int, boolean, long, float, double, etc
        Obvious classes
                 String, Date, BigDecimal, BigInteger, Enum, etc
        Arrays and Collections
                 Map, List, Set, Iterator, ...
        JavaBeans and Objects
        XML objects
                 DOM, XOM, JDom, Dom4J


© SitePen, Inc. 2008. All Rights Reserved
© SitePen, Inc. 2008. All Rights Reserved
Since we last talked ...



        TIBCO General Interface
        SitePen
        http://svn.directwebremoting.org




© SitePen, Inc. 2008. All Rights Reserved
Named Parameters



© SitePen, Inc. 2008. All Rights Reserved
Named Parameters



        DWR will create client-side classes to look like
        server-side classes to make passing parameters
        easy




© SitePen, Inc. 2008. All Rights Reserved
Named Parameters

          Java:

          public interface Person { ... }
          public class Employee implements Person { ... }
          public class Manager extends Employee { ... }

          public HumanResources {
            public void addPerson(Person p) { ... }
          }

          JavaScript:

          Manager m = new Manager();
          HumanResources.addPerson(m);




© SitePen, Inc. 2008. All Rights Reserved
Named Parameters



        Why?
                 • Inheritance is useful in places
                 • It saves creating addEmployee() and addManager()
                   methods




© SitePen, Inc. 2008. All Rights Reserved
Lightweight Named
                                      Parameters



© SitePen, Inc. 2008. All Rights Reserved
Lightweight Named Parameters




        DWR also allows a lighter-weight method of
        declaring types




© SitePen, Inc. 2008. All Rights Reserved
Lightweight Named Parameters

          Java:

          public interface Person { ... }
          public class Employee implements Person { ... }
          public class Manager extends Employee { ... }

          public HumanResources {
            public void addPerson(Person p) { ... }
          }

          JavaScript:

          var m = { $dwrClassName:'Manager', firstname:'Joe', ...};
          HumanResources.addPerson(m);




© SitePen, Inc. 2008. All Rights Reserved
Lightweight Named Parameters



        Why?
                 • Everything as for Named Parameters
                 • But sometimes you get an object from somewhere
                   else




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: File Upload



© SitePen, Inc. 2008. All Rights Reserved
Binary Files: File Upload


        DWR has always had a long list of things that it will
        marshall including Dates, DOM trees, etc


        In addition, DWR will now marshall binary files just
        as if they were the text resources it handles now




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: File Upload

          Java:

          public Remoted {
            public void receiveBinaryFile(byte[] uploaded) { ... }
          }

          HTML:

          <input id='fileId' type='file'/>

          JavaScript:

          var binary = dwr.util.getValue('fileId');
          Remoted.receiveBinaryFile(binary);




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: File Upload

        Will marshall to:
                 • byte[]
                 • java.awt.BufferedImage
                 • java.io.InputStream
                 • org.directwebremoting.io.FileTransfer
                   (gives access to filename and mime-type in
                   addition to the contents)




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: File Upload


        Why?
                 • This is a lot easier than using commons-fileupload
                   or similar
                 • We can provide integration with progress bar
                   widgets




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: Download



© SitePen, Inc. 2008. All Rights Reserved
Binary Files: Download


        Binary file handling is 2 way. It’s good for:
                 • Images
                 • PDF files
                 • Word, Excel documents
                 • etc.




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: Download

          Java:
          public Remoted {
            public void getPDF(String contents) {
                        ByteArrayOutputStream buf = new ByteArrayOutputStream();
                        Document doc = new Document();
                        PdfWriter.getInstance(doc, buf);
                        doc.open();
                        doc.add(new Paragraph(contents));
                        doc.close();
                        return new FileTransfer(quot;ex.pdfquot;, quot;application/pdfquot;, buf.toByteArray());
          }

          JavaScript:
          Remoted.getPDF('Joe', function(data) {
            dwr.engine.openInDownload(data);
          });




© SitePen, Inc. 2008. All Rights Reserved
Binary Files: Download



        Why?
                 • This is a lot easier than creating a special PDF/
                   image/etc serving servlet




© SitePen, Inc. 2008. All Rights Reserved
Javascript extending Java



© SitePen, Inc. 2008. All Rights Reserved
Javascript extending Java




        DWR will allow you to implement Java interfaces
        using JavaScript




© SitePen, Inc. 2008. All Rights Reserved
Javascript extending Java
           Java:
          public interface BazListener {
            void somethingChanged(String msg);
          }
          public class Remote {
            public void addBazListener(BazListener bl) { ... }

                public void calledLater() {
                  for (BazListener bl : listeners)
                    bl.somethingChanged(quot;JS objects can implement Java interfacesquot;);
                }
                ...
          }

          JavaScript:
          function BazListener() {this.$dwrByRef;}
          BazListener.prototype.somethingChanged = function(msg){alert(msg);};

          var bl = new BazListener();
          Remote.addBazListener(bl);




© SitePen, Inc. 2008. All Rights Reserved
Javascript extending Java



        Why?
                 • Intuitive way to interact
                 • Easy Pub-sub
                 • Allows interaction with existing APIs




© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax



© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax



        Previously there were some scalability limitations
        with the 2.0 reverse ajax API.
        3.0 deprecates the problem areas.




© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax


        Reverse Ajax proxies no longer take a list of
        ScriptSessions in the constructor, they just write to
        the current ‘destination’


        The Browser API allows you to change the current
        ‘destination’




© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax


          // The default destination is the browser
          // that caused the current action to happen.
          Window.alert(quot;Helloquot;);

          // Non DWR thread have no default destination
          Thread t = new Thread(new Runnable()) {
            public void run() {
              // Error
              Window.alert(quot;Helloquot;);
            }
          });




© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax

          // Set the destination to be all browsers that
          // are looking at the current page
          Browser.withCurrentPage(new Runnable()) {
            public void run() {
              Window.alert(quot;Helloquot;);
            }
          });

          // Set the destination to be all browsers that
          // are looking at the current page
          Browser.withCurrentPage(quot;index.htmlquot;, new Runnable()) {
            public void run() {
              Window.alert(quot;Helloquot;);
            }
          });



© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax



          // Broadcast to everyone
          Browser.withAllSessions(...);

          // Broadcast to subsets
          Browser.with*Filtered(scriptSesssionFilter, ...);

          // To a known individual
          Browser.withSession(sessionId, ...);




© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax



        Why?
                 • It’s generally easier to use
                 • It decouples generation from routing
                 • It scales




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs



© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs



                                            Reverse Ajax != Comet


                   Reverse Ajax == Comet + Polling + Piggyback




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: JS Level



          // Low level: Use server-side W3C DOM methods
          Element ele = doc.createElement(quot;pquot;);

          ScriptSessions.addFunctionCall(
                       quot;document.body.appendChildquot;,
                       ele);




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: JS Level




          // Low level: Any arbitrary JavaScript
          String s = quot;if (document.all) window.alert('IE');quot;;

          ScriptSessions.addScript(s);




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: DOM Level



          // Some methods from Window and Document
          import javax.servlet.http.Cookie;
          import org.directwebremoting.ui.browser.Document;

          Cookie c = new Cookie(quot;namequot;, quot;valuequot;);
          Document.setCookie(c);




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: dwr.util



          // dwr.util in Java
          import org.directwebremoting.ui.dwr.Util;

          String[] opts = new String[] {quot;onequot;,quot;twoquot;,...};
          Util.addOptions(quot;liquot;, opts);




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: Scriptaculous




          // Scriptaculous Effects in Java
          import org.directwebremoting.ui.scriptaculous.Effect;

          Effect.fade(quot;someIdquot;);




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: TIBCO GI


          // TIBCO General Interface in Java
          import jsx3.GI;
          import jsx3.app.*;
          import jsx3.gui.*;

          Server server = GI.getServer(quot;servernamequot;);
          TextBox phoneNum = server.getJSXByName(quot;phoneNumquot;,
                                             TextBox.class);

          phoneNum.setValue(quot;servernamequot;);




© SitePen, Inc. 2008. All Rights Reserved
Reverse Ajax APIs: Dojo



          // Dojo in Java
          import org.dojotoolkit.dijit.Dijit;
          import org.dojotoolkit.dijit.Editor;

          Editor e = Dijit.byId(quot;pricequot;, Editor.class);
          e.setValue(42);




© SitePen, Inc. 2008. All Rights Reserved
Scalable Reverse Ajax

        Why?
                 • A full range of APIs for dynamically updating client
                   data
                 • DWR doesn’t do widgets, but it does talk to the
                   people that do


        Drapgen can be used to create and maintain large
        APIs




© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store



© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store




        DWR now implements all 4 interfaces to allow Dojo
        to sync data with Java code on the server




© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store


          Java:

          // Load the data somehow
          Map<String, Person> ppl = ...;

          // Create an implementation of StoreProvider to hold the data
          MapStoreProvider provider = new MapStoreProvider(ppl, Person.class);

          // Tell DWR to expose the data to the internet
          Directory.register(quot;testServerDataquot;, provider);




© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store

          HTML:
          <table id=quot;gridquot; dojoType=quot;dojox.grid.DataGridquot; ><tr>
            <th field=quot;namequot; width=quot;120pxquot; editable=quot;truequot;>Name</th>
            ...
          </tr></table>



          JavaScript:
          dojo.registerModulePath(quot;dwrquot;, quot;path/from/dojo/to/dwrquot;);
          dojo.require(quot;dwr.data.Storequot;);

          dwrStore = new dwr.data.Store(quot;testServerDataquot;, { subscribe:true });
          dijit.byId(quot;gridquot;).setStore(dwrStore);




© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store


          Java:

          // The StoreProvider from earlier
          MapStoreProvider provider = ...

          // Get a representation of the internal data
          Map<String, Person> data = provider.asMap();

          // Mutate it
          data.addPerson(new Person(...));

          // The browsers viewing the data automagically update




© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store


        Why?
                 • Data-Sync APIs are hard to get right, but are really
                   simple to use
                 • There is lots of potential for network level
                   optimization




© SitePen, Inc. 2008. All Rights Reserved
JSON / JSONP / JSON-RPC



© SitePen, Inc. 2008. All Rights Reserved
Dojo Data Store



        DWR now supports:
                 • plain JSON
                 • JSONP
                 • JSON-RPC




© SitePen, Inc. 2008. All Rights Reserved
JSONP

          Java:

          public class Demo {
            public sayHello(String name) {
              return quot;Hello, quot; + name;
            }
          }

          Shell:

          $ wget http://example.com/app/dwr/jsonp/Demo/sayHello? ↩
                                callback=callback&param0=quot;Joequot;

          -> callback(quot;Hello, Joequot;);




© SitePen, Inc. 2008. All Rights Reserved
JSONP
          Dojo:

          dojo.io.script.get({
            url:'http://example.com/app/dwr/jsonp/Demo/sayHello',
            content:{param:'Joe'}
          }).addCallback(function() { ... });

          JQuery:

          $.ajax({
            dataType:'jsonp',
            data:'param=Joe',
            url:'http://example.com/app/dwr/jsonp/Demo/sayHello',
            success:function () { ... },
          });



© SitePen, Inc. 2008. All Rights Reserved
JSON / JSONP / JSON-RPC


        Why?
                 • To allow DWR to remote functions to things other
                   than a DWR client
                 • ‘DWRP’ is designed to be something we can change
                   without a long deprecation process




© SitePen, Inc. 2008. All Rights Reserved
Varargs



© SitePen, Inc. 2008. All Rights Reserved
Varargs




        You can now call methods with a vararg parameter




© SitePen, Inc. 2008. All Rights Reserved
Varargs


          Java:

          public Remoted {
            public void method(String... arg) { ... }
          }

          JavaScript:

          Remoted.method(quot;Onequot;, quot;Twoquot;, quot;Threequot;);




© SitePen, Inc. 2008. All Rights Reserved
Varargs

        Why?
                 • It saves the hassle of wrapping options in an array
                   or collection before a method is called


        Alert:
                 • It could break some corner cases when mixing
                   servlet parameters with normal parameters




© SitePen, Inc. 2008. All Rights Reserved
Overloaded Methods



© SitePen, Inc. 2008. All Rights Reserved
Overloaded Methods




        Previously DWR prevented you from reliably calling
        overloaded methods




© SitePen, Inc. 2008. All Rights Reserved
Overloaded Methods

          Java:
          public Remoted {
            public void method(int num) {
                         log.debug(quot;int method called with quot; + num);
                }
                 public void method(String str) {
                         log.debug(quot;String method called with quot; + str);
                }
          }

          JavaScript:
          Remoted.method(quot;String Paramquot;);
          Remoted.method(42);




© SitePen, Inc. 2008. All Rights Reserved
Overloaded Methods



        Why?
                 • It saves you from creating multiple proxy methods
                   to existing APIs




© SitePen, Inc. 2008. All Rights Reserved
What’s Next



© SitePen, Inc. 2008. All Rights Reserved
Top Directions for DWR 3.1

        Shorter release cycle
        Gears
        SMD
        Dojo:
                 • Reverse Ajax API support
                 • Auto-build
        Rest




© SitePen, Inc. 2008. All Rights Reserved
Any Questions?


        • http://directwebremoting.org
        • http://sitepen.com



© SitePen, Inc. 2008. All Rights Reserved

Weitere ähnliche Inhalte

Was ist angesagt?

Automated attendence system PPT
Automated attendence system PPTAutomated attendence system PPT
Automated attendence system PPTThejeshReddyJ
 
Synopsis of Fee Management System
Synopsis of Fee Management SystemSynopsis of Fee Management System
Synopsis of Fee Management SystemDivya_Gupta19
 
Android alumni application
Android alumni applicationAndroid alumni application
Android alumni applicationdharmawath
 
Face identification
Face  identificationFace  identification
Face identification27vipin92
 
Online bus ticket management system project for system analysis and design (d...
Online bus ticket management system project for system analysis and design (d...Online bus ticket management system project for system analysis and design (d...
Online bus ticket management system project for system analysis and design (d...Daffodil International University
 
22598435 project-on-banking-system-in-mis-pdf(1)
22598435 project-on-banking-system-in-mis-pdf(1)22598435 project-on-banking-system-in-mis-pdf(1)
22598435 project-on-banking-system-in-mis-pdf(1)Sruthi S
 
Library management (use case diagram Software engineering)
Library management (use case  diagram Software engineering)Library management (use case  diagram Software engineering)
Library management (use case diagram Software engineering)kiran Patel
 
How to configure a hive high availability connection with zeppelin
How to configure a hive high availability connection with zeppelinHow to configure a hive high availability connection with zeppelin
How to configure a hive high availability connection with zeppelinTiago Simões
 
Hands on MapR -- Viadea
Hands on MapR -- ViadeaHands on MapR -- Viadea
Hands on MapR -- Viadeaviadea
 
Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)
Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)
Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)WE-IT TUTORIALS
 
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
 No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ... No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...Amazon Web Services
 

Was ist angesagt? (13)

E-library mangament system
E-library mangament systemE-library mangament system
E-library mangament system
 
Automated attendence system PPT
Automated attendence system PPTAutomated attendence system PPT
Automated attendence system PPT
 
Synopsis of Fee Management System
Synopsis of Fee Management SystemSynopsis of Fee Management System
Synopsis of Fee Management System
 
Android alumni application
Android alumni applicationAndroid alumni application
Android alumni application
 
FreeBSD and Hardening Web Server
FreeBSD and Hardening Web ServerFreeBSD and Hardening Web Server
FreeBSD and Hardening Web Server
 
Face identification
Face  identificationFace  identification
Face identification
 
Online bus ticket management system project for system analysis and design (d...
Online bus ticket management system project for system analysis and design (d...Online bus ticket management system project for system analysis and design (d...
Online bus ticket management system project for system analysis and design (d...
 
22598435 project-on-banking-system-in-mis-pdf(1)
22598435 project-on-banking-system-in-mis-pdf(1)22598435 project-on-banking-system-in-mis-pdf(1)
22598435 project-on-banking-system-in-mis-pdf(1)
 
Library management (use case diagram Software engineering)
Library management (use case  diagram Software engineering)Library management (use case  diagram Software engineering)
Library management (use case diagram Software engineering)
 
How to configure a hive high availability connection with zeppelin
How to configure a hive high availability connection with zeppelinHow to configure a hive high availability connection with zeppelin
How to configure a hive high availability connection with zeppelin
 
Hands on MapR -- Viadea
Hands on MapR -- ViadeaHands on MapR -- Viadea
Hands on MapR -- Viadea
 
Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)
Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)
Tycs sem 5 asp.net notes unit 1 2 3 4 (2017)
 
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
 No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ... No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
 

Andere mochten auch

SBML: What Is It About?
SBML: What Is It About?SBML: What Is It About?
SBML: What Is It About?Mike Hucka
 
Lenovo's 'Idea Tweetathon' Contest Guidelines
Lenovo's 'Idea Tweetathon' Contest GuidelinesLenovo's 'Idea Tweetathon' Contest Guidelines
Lenovo's 'Idea Tweetathon' Contest GuidelinesLenovo
 
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSMichael Neale
 
The Role of Standards in BPM
The Role of Standards in BPMThe Role of Standards in BPM
The Role of Standards in BPMSandy Kemsley
 
Specialist in personal injury law
Specialist in personal injury lawSpecialist in personal injury law
Specialist in personal injury lawParamount Lawyers
 
The Most Misunderstood “Buzzword” of All Time: Content Marketing
The Most Misunderstood “Buzzword” of All Time: Content MarketingThe Most Misunderstood “Buzzword” of All Time: Content Marketing
The Most Misunderstood “Buzzword” of All Time: Content MarketingGhergich & Co.
 
Halkin Dusmanlari
Halkin DusmanlariHalkin Dusmanlari
Halkin Dusmanlarikaanay
 
Streamlining the Quota Process for a World-Class Sales Organization
Streamlining the Quota Process for a World-Class Sales OrganizationStreamlining the Quota Process for a World-Class Sales Organization
Streamlining the Quota Process for a World-Class Sales OrganizationCallidus Software
 
Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)
Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)
Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)Andrea Rossetti
 
Callidus Software Product Suite Overview: What's New
Callidus Software Product Suite Overview: What's NewCallidus Software Product Suite Overview: What's New
Callidus Software Product Suite Overview: What's NewCallidus Software
 
APMP Knowledge Sharing Tools 11 Oct07
APMP  Knowledge Sharing Tools 11 Oct07APMP  Knowledge Sharing Tools 11 Oct07
APMP Knowledge Sharing Tools 11 Oct07guest66ff7d
 
01 Paolo Lessio, Processo civile telematico
01 Paolo Lessio, Processo civile telematico01 Paolo Lessio, Processo civile telematico
01 Paolo Lessio, Processo civile telematicoAndrea Rossetti
 
02 - Paolo Lessio, Processo civile telematico
02 - Paolo Lessio, Processo civile telematico02 - Paolo Lessio, Processo civile telematico
02 - Paolo Lessio, Processo civile telematicoAndrea Rossetti
 
New Media Addicts Anonymous
New Media Addicts AnonymousNew Media Addicts Anonymous
New Media Addicts AnonymousGeert Wissink
 
Andrea Cavalloni, Digital Rights Management: Il caso Sony-BMG
Andrea Cavalloni, Digital Rights Management:Il caso Sony-BMGAndrea Cavalloni, Digital Rights Management:Il caso Sony-BMG
Andrea Cavalloni, Digital Rights Management: Il caso Sony-BMGAndrea Rossetti
 
Hollywood vs Silicon Valley: Open Video als Vermittler
Hollywood vs Silicon Valley: Open Video als VermittlerHollywood vs Silicon Valley: Open Video als Vermittler
Hollywood vs Silicon Valley: Open Video als VermittlerBertram Gugel
 
Film Titles
Film TitlesFilm Titles
Film Titlesmezusa
 
Decisions and Time in the Information Society
Decisions and Time in the Information SocietyDecisions and Time in the Information Society
Decisions and Time in the Information Societyjexxon
 

Andere mochten auch (20)

SBML: What Is It About?
SBML: What Is It About?SBML: What Is It About?
SBML: What Is It About?
 
Lenovo's 'Idea Tweetathon' Contest Guidelines
Lenovo's 'Idea Tweetathon' Contest GuidelinesLenovo's 'Idea Tweetathon' Contest Guidelines
Lenovo's 'Idea Tweetathon' Contest Guidelines
 
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
 
The Role of Standards in BPM
The Role of Standards in BPMThe Role of Standards in BPM
The Role of Standards in BPM
 
Specialist in personal injury law
Specialist in personal injury lawSpecialist in personal injury law
Specialist in personal injury law
 
The Most Misunderstood “Buzzword” of All Time: Content Marketing
The Most Misunderstood “Buzzword” of All Time: Content MarketingThe Most Misunderstood “Buzzword” of All Time: Content Marketing
The Most Misunderstood “Buzzword” of All Time: Content Marketing
 
Halkin Dusmanlari
Halkin DusmanlariHalkin Dusmanlari
Halkin Dusmanlari
 
Streamlining the Quota Process for a World-Class Sales Organization
Streamlining the Quota Process for a World-Class Sales OrganizationStreamlining the Quota Process for a World-Class Sales Organization
Streamlining the Quota Process for a World-Class Sales Organization
 
Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)
Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)
Stefano Ricci, PRIVACY E SERVIZI DELLA SOCIETA' DELL'INFORMAZIONE (2)
 
Callidus Software Product Suite Overview: What's New
Callidus Software Product Suite Overview: What's NewCallidus Software Product Suite Overview: What's New
Callidus Software Product Suite Overview: What's New
 
Agencies Blogging
Agencies BloggingAgencies Blogging
Agencies Blogging
 
APMP Knowledge Sharing Tools 11 Oct07
APMP  Knowledge Sharing Tools 11 Oct07APMP  Knowledge Sharing Tools 11 Oct07
APMP Knowledge Sharing Tools 11 Oct07
 
01 Paolo Lessio, Processo civile telematico
01 Paolo Lessio, Processo civile telematico01 Paolo Lessio, Processo civile telematico
01 Paolo Lessio, Processo civile telematico
 
02 - Paolo Lessio, Processo civile telematico
02 - Paolo Lessio, Processo civile telematico02 - Paolo Lessio, Processo civile telematico
02 - Paolo Lessio, Processo civile telematico
 
New Media Addicts Anonymous
New Media Addicts AnonymousNew Media Addicts Anonymous
New Media Addicts Anonymous
 
Andrea Cavalloni, Digital Rights Management: Il caso Sony-BMG
Andrea Cavalloni, Digital Rights Management:Il caso Sony-BMGAndrea Cavalloni, Digital Rights Management:Il caso Sony-BMG
Andrea Cavalloni, Digital Rights Management: Il caso Sony-BMG
 
Hollywood vs Silicon Valley: Open Video als Vermittler
Hollywood vs Silicon Valley: Open Video als VermittlerHollywood vs Silicon Valley: Open Video als Vermittler
Hollywood vs Silicon Valley: Open Video als Vermittler
 
Film Titles
Film TitlesFilm Titles
Film Titles
 
Decisions and Time in the Information Society
Decisions and Time in the Information SocietyDecisions and Time in the Information Society
Decisions and Time in the Information Society
 
6 Takes
6 Takes6 Takes
6 Takes
 

Ähnlich wie What's new in DWR version 3

Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web FrameworkLuther Baker
 
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
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Hamed Hatami
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiJackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008Association Paris-Web
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyonddion
 
Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...Boris Kravtsov
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta jaxconf
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWRgouthamrv
 
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
Getting Started with WebSocket and Server-Sent Events using Java by Arun GuptaGetting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
Getting Started with WebSocket and Server-Sent Events using Java by Arun GuptaCodemotion
 
Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014Jagadish Prasath
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesJohn Brunswick
 

Ähnlich wie What's new in DWR version 3 (20)

AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
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
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Json generation
Json generationJson generation
Json generation
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyond
 
Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
 
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
Getting Started with WebSocket and Server-Sent Events using Java by Arun GuptaGetting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
 
Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 

Kürzlich hochgeladen

MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 

Kürzlich hochgeladen (20)

MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 

What's new in DWR version 3

  • 1. What’s new in DWR v3 Joe Walker DWR Lead Developer SitePen UK
  • 2. Recap Since we last talked ... Named Parameters Binary Files JavaScript Extending Java Better Reverse Ajax Data Sync: Dojo Data Store JSON / JSONP / JSON-RPC Varargs and Overloaded Methods What’s Next © SitePen, Inc. 2008. All Rights Reserved
  • 3. Recap © SitePen, Inc. 2008. All Rights Reserved
  • 4. © SitePen, Inc. 2008. All Rights Reserved
  • 5. Marshalling Types Primitive types, and their Object counterparts int, boolean, long, float, double, etc Obvious classes String, Date, BigDecimal, BigInteger, Enum, etc Arrays and Collections Map, List, Set, Iterator, ... JavaBeans and Objects XML objects DOM, XOM, JDom, Dom4J © SitePen, Inc. 2008. All Rights Reserved
  • 6. © SitePen, Inc. 2008. All Rights Reserved
  • 7. Since we last talked ... TIBCO General Interface SitePen http://svn.directwebremoting.org © SitePen, Inc. 2008. All Rights Reserved
  • 8. Named Parameters © SitePen, Inc. 2008. All Rights Reserved
  • 9. Named Parameters DWR will create client-side classes to look like server-side classes to make passing parameters easy © SitePen, Inc. 2008. All Rights Reserved
  • 10. Named Parameters Java: public interface Person { ... } public class Employee implements Person { ... } public class Manager extends Employee { ... } public HumanResources { public void addPerson(Person p) { ... } } JavaScript: Manager m = new Manager(); HumanResources.addPerson(m); © SitePen, Inc. 2008. All Rights Reserved
  • 11. Named Parameters Why? • Inheritance is useful in places • It saves creating addEmployee() and addManager() methods © SitePen, Inc. 2008. All Rights Reserved
  • 12. Lightweight Named Parameters © SitePen, Inc. 2008. All Rights Reserved
  • 13. Lightweight Named Parameters DWR also allows a lighter-weight method of declaring types © SitePen, Inc. 2008. All Rights Reserved
  • 14. Lightweight Named Parameters Java: public interface Person { ... } public class Employee implements Person { ... } public class Manager extends Employee { ... } public HumanResources { public void addPerson(Person p) { ... } } JavaScript: var m = { $dwrClassName:'Manager', firstname:'Joe', ...}; HumanResources.addPerson(m); © SitePen, Inc. 2008. All Rights Reserved
  • 15. Lightweight Named Parameters Why? • Everything as for Named Parameters • But sometimes you get an object from somewhere else © SitePen, Inc. 2008. All Rights Reserved
  • 16. Binary Files: File Upload © SitePen, Inc. 2008. All Rights Reserved
  • 17. Binary Files: File Upload DWR has always had a long list of things that it will marshall including Dates, DOM trees, etc In addition, DWR will now marshall binary files just as if they were the text resources it handles now © SitePen, Inc. 2008. All Rights Reserved
  • 18. Binary Files: File Upload Java: public Remoted { public void receiveBinaryFile(byte[] uploaded) { ... } } HTML: <input id='fileId' type='file'/> JavaScript: var binary = dwr.util.getValue('fileId'); Remoted.receiveBinaryFile(binary); © SitePen, Inc. 2008. All Rights Reserved
  • 19. Binary Files: File Upload Will marshall to: • byte[] • java.awt.BufferedImage • java.io.InputStream • org.directwebremoting.io.FileTransfer (gives access to filename and mime-type in addition to the contents) © SitePen, Inc. 2008. All Rights Reserved
  • 20. Binary Files: File Upload Why? • This is a lot easier than using commons-fileupload or similar • We can provide integration with progress bar widgets © SitePen, Inc. 2008. All Rights Reserved
  • 21. Binary Files: Download © SitePen, Inc. 2008. All Rights Reserved
  • 22. Binary Files: Download Binary file handling is 2 way. It’s good for: • Images • PDF files • Word, Excel documents • etc. © SitePen, Inc. 2008. All Rights Reserved
  • 23. Binary Files: Download Java: public Remoted { public void getPDF(String contents) { ByteArrayOutputStream buf = new ByteArrayOutputStream(); Document doc = new Document(); PdfWriter.getInstance(doc, buf); doc.open(); doc.add(new Paragraph(contents)); doc.close(); return new FileTransfer(quot;ex.pdfquot;, quot;application/pdfquot;, buf.toByteArray()); } JavaScript: Remoted.getPDF('Joe', function(data) { dwr.engine.openInDownload(data); }); © SitePen, Inc. 2008. All Rights Reserved
  • 24. Binary Files: Download Why? • This is a lot easier than creating a special PDF/ image/etc serving servlet © SitePen, Inc. 2008. All Rights Reserved
  • 25. Javascript extending Java © SitePen, Inc. 2008. All Rights Reserved
  • 26. Javascript extending Java DWR will allow you to implement Java interfaces using JavaScript © SitePen, Inc. 2008. All Rights Reserved
  • 27. Javascript extending Java Java: public interface BazListener { void somethingChanged(String msg); } public class Remote { public void addBazListener(BazListener bl) { ... } public void calledLater() { for (BazListener bl : listeners) bl.somethingChanged(quot;JS objects can implement Java interfacesquot;); } ... } JavaScript: function BazListener() {this.$dwrByRef;} BazListener.prototype.somethingChanged = function(msg){alert(msg);}; var bl = new BazListener(); Remote.addBazListener(bl); © SitePen, Inc. 2008. All Rights Reserved
  • 28. Javascript extending Java Why? • Intuitive way to interact • Easy Pub-sub • Allows interaction with existing APIs © SitePen, Inc. 2008. All Rights Reserved
  • 29. Scalable Reverse Ajax © SitePen, Inc. 2008. All Rights Reserved
  • 30. Scalable Reverse Ajax Previously there were some scalability limitations with the 2.0 reverse ajax API. 3.0 deprecates the problem areas. © SitePen, Inc. 2008. All Rights Reserved
  • 31. Scalable Reverse Ajax Reverse Ajax proxies no longer take a list of ScriptSessions in the constructor, they just write to the current ‘destination’ The Browser API allows you to change the current ‘destination’ © SitePen, Inc. 2008. All Rights Reserved
  • 32. Scalable Reverse Ajax // The default destination is the browser // that caused the current action to happen. Window.alert(quot;Helloquot;); // Non DWR thread have no default destination Thread t = new Thread(new Runnable()) { public void run() { // Error Window.alert(quot;Helloquot;); } }); © SitePen, Inc. 2008. All Rights Reserved
  • 33. Scalable Reverse Ajax // Set the destination to be all browsers that // are looking at the current page Browser.withCurrentPage(new Runnable()) { public void run() { Window.alert(quot;Helloquot;); } }); // Set the destination to be all browsers that // are looking at the current page Browser.withCurrentPage(quot;index.htmlquot;, new Runnable()) { public void run() { Window.alert(quot;Helloquot;); } }); © SitePen, Inc. 2008. All Rights Reserved
  • 34. Scalable Reverse Ajax // Broadcast to everyone Browser.withAllSessions(...); // Broadcast to subsets Browser.with*Filtered(scriptSesssionFilter, ...); // To a known individual Browser.withSession(sessionId, ...); © SitePen, Inc. 2008. All Rights Reserved
  • 35. Scalable Reverse Ajax Why? • It’s generally easier to use • It decouples generation from routing • It scales © SitePen, Inc. 2008. All Rights Reserved
  • 36. Reverse Ajax APIs © SitePen, Inc. 2008. All Rights Reserved
  • 37. Reverse Ajax APIs Reverse Ajax != Comet Reverse Ajax == Comet + Polling + Piggyback © SitePen, Inc. 2008. All Rights Reserved
  • 38. Reverse Ajax APIs: JS Level // Low level: Use server-side W3C DOM methods Element ele = doc.createElement(quot;pquot;); ScriptSessions.addFunctionCall( quot;document.body.appendChildquot;, ele); © SitePen, Inc. 2008. All Rights Reserved
  • 39. Reverse Ajax APIs: JS Level // Low level: Any arbitrary JavaScript String s = quot;if (document.all) window.alert('IE');quot;; ScriptSessions.addScript(s); © SitePen, Inc. 2008. All Rights Reserved
  • 40. Reverse Ajax APIs: DOM Level // Some methods from Window and Document import javax.servlet.http.Cookie; import org.directwebremoting.ui.browser.Document; Cookie c = new Cookie(quot;namequot;, quot;valuequot;); Document.setCookie(c); © SitePen, Inc. 2008. All Rights Reserved
  • 41. Reverse Ajax APIs: dwr.util // dwr.util in Java import org.directwebremoting.ui.dwr.Util; String[] opts = new String[] {quot;onequot;,quot;twoquot;,...}; Util.addOptions(quot;liquot;, opts); © SitePen, Inc. 2008. All Rights Reserved
  • 42. Reverse Ajax APIs: Scriptaculous // Scriptaculous Effects in Java import org.directwebremoting.ui.scriptaculous.Effect; Effect.fade(quot;someIdquot;); © SitePen, Inc. 2008. All Rights Reserved
  • 43. Reverse Ajax APIs: TIBCO GI // TIBCO General Interface in Java import jsx3.GI; import jsx3.app.*; import jsx3.gui.*; Server server = GI.getServer(quot;servernamequot;); TextBox phoneNum = server.getJSXByName(quot;phoneNumquot;, TextBox.class); phoneNum.setValue(quot;servernamequot;); © SitePen, Inc. 2008. All Rights Reserved
  • 44. Reverse Ajax APIs: Dojo // Dojo in Java import org.dojotoolkit.dijit.Dijit; import org.dojotoolkit.dijit.Editor; Editor e = Dijit.byId(quot;pricequot;, Editor.class); e.setValue(42); © SitePen, Inc. 2008. All Rights Reserved
  • 45. Scalable Reverse Ajax Why? • A full range of APIs for dynamically updating client data • DWR doesn’t do widgets, but it does talk to the people that do Drapgen can be used to create and maintain large APIs © SitePen, Inc. 2008. All Rights Reserved
  • 46. Dojo Data Store © SitePen, Inc. 2008. All Rights Reserved
  • 47. Dojo Data Store DWR now implements all 4 interfaces to allow Dojo to sync data with Java code on the server © SitePen, Inc. 2008. All Rights Reserved
  • 48. Dojo Data Store Java: // Load the data somehow Map<String, Person> ppl = ...; // Create an implementation of StoreProvider to hold the data MapStoreProvider provider = new MapStoreProvider(ppl, Person.class); // Tell DWR to expose the data to the internet Directory.register(quot;testServerDataquot;, provider); © SitePen, Inc. 2008. All Rights Reserved
  • 49. Dojo Data Store HTML: <table id=quot;gridquot; dojoType=quot;dojox.grid.DataGridquot; ><tr> <th field=quot;namequot; width=quot;120pxquot; editable=quot;truequot;>Name</th> ... </tr></table> JavaScript: dojo.registerModulePath(quot;dwrquot;, quot;path/from/dojo/to/dwrquot;); dojo.require(quot;dwr.data.Storequot;); dwrStore = new dwr.data.Store(quot;testServerDataquot;, { subscribe:true }); dijit.byId(quot;gridquot;).setStore(dwrStore); © SitePen, Inc. 2008. All Rights Reserved
  • 50. Dojo Data Store Java: // The StoreProvider from earlier MapStoreProvider provider = ... // Get a representation of the internal data Map<String, Person> data = provider.asMap(); // Mutate it data.addPerson(new Person(...)); // The browsers viewing the data automagically update © SitePen, Inc. 2008. All Rights Reserved
  • 51. Dojo Data Store Why? • Data-Sync APIs are hard to get right, but are really simple to use • There is lots of potential for network level optimization © SitePen, Inc. 2008. All Rights Reserved
  • 52. JSON / JSONP / JSON-RPC © SitePen, Inc. 2008. All Rights Reserved
  • 53. Dojo Data Store DWR now supports: • plain JSON • JSONP • JSON-RPC © SitePen, Inc. 2008. All Rights Reserved
  • 54. JSONP Java: public class Demo { public sayHello(String name) { return quot;Hello, quot; + name; } } Shell: $ wget http://example.com/app/dwr/jsonp/Demo/sayHello? ↩ callback=callback&param0=quot;Joequot; -> callback(quot;Hello, Joequot;); © SitePen, Inc. 2008. All Rights Reserved
  • 55. JSONP Dojo: dojo.io.script.get({ url:'http://example.com/app/dwr/jsonp/Demo/sayHello', content:{param:'Joe'} }).addCallback(function() { ... }); JQuery: $.ajax({ dataType:'jsonp', data:'param=Joe', url:'http://example.com/app/dwr/jsonp/Demo/sayHello', success:function () { ... }, }); © SitePen, Inc. 2008. All Rights Reserved
  • 56. JSON / JSONP / JSON-RPC Why? • To allow DWR to remote functions to things other than a DWR client • ‘DWRP’ is designed to be something we can change without a long deprecation process © SitePen, Inc. 2008. All Rights Reserved
  • 57. Varargs © SitePen, Inc. 2008. All Rights Reserved
  • 58. Varargs You can now call methods with a vararg parameter © SitePen, Inc. 2008. All Rights Reserved
  • 59. Varargs Java: public Remoted { public void method(String... arg) { ... } } JavaScript: Remoted.method(quot;Onequot;, quot;Twoquot;, quot;Threequot;); © SitePen, Inc. 2008. All Rights Reserved
  • 60. Varargs Why? • It saves the hassle of wrapping options in an array or collection before a method is called Alert: • It could break some corner cases when mixing servlet parameters with normal parameters © SitePen, Inc. 2008. All Rights Reserved
  • 61. Overloaded Methods © SitePen, Inc. 2008. All Rights Reserved
  • 62. Overloaded Methods Previously DWR prevented you from reliably calling overloaded methods © SitePen, Inc. 2008. All Rights Reserved
  • 63. Overloaded Methods Java: public Remoted { public void method(int num) { log.debug(quot;int method called with quot; + num); } public void method(String str) { log.debug(quot;String method called with quot; + str); } } JavaScript: Remoted.method(quot;String Paramquot;); Remoted.method(42); © SitePen, Inc. 2008. All Rights Reserved
  • 64. Overloaded Methods Why? • It saves you from creating multiple proxy methods to existing APIs © SitePen, Inc. 2008. All Rights Reserved
  • 65. What’s Next © SitePen, Inc. 2008. All Rights Reserved
  • 66. Top Directions for DWR 3.1 Shorter release cycle Gears SMD Dojo: • Reverse Ajax API support • Auto-build Rest © SitePen, Inc. 2008. All Rights Reserved
  • 67. Any Questions? • http://directwebremoting.org • http://sitepen.com © SitePen, Inc. 2008. All Rights Reserved