SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
L2: Web Application Development
Direct Web Remoting (DWR): Ajax made easy…

                          Daniel Bryant
     Department of Computing, FEPS (d.bryant@surrey.ac.uk)
            Tai-Dev Ltd, (daniel.bryant@tai-dev.co.uk)
Today’s roadmap...
•   My life story (in under 3 minutes)…

•   Quick review - so, what is Ajax? (Old school vs new school)

•   DWR
       Introduction
       Looking deeper into DWR (client-side/server-side)
       Implementation
       Demo (and debugging)


•   Quick case study – TriOpsis Ltd

•   DWR is awesome!! But are there any disadvantages?

•   Review
My life story (abridged)…

•   Studying at Surrey for 8 years
       BSc Computing and IT - Placement at DTI (now called BERR, DBIS etc. etc...)
       MSc Internet Computing


•   PhD Student within the Department of Computing
       Argumentation “how humans reason”
       Software Agents “mobile and/or intelligent code”


•   JEE, Web 2.0, J2ME & RDBMS Consultant
       Working freelance for the past 5 years
       Started Tai-Dev Ltd 1 year ago (http://tai-dev.blog.co.uk/)
       J2EE, JEE 5, JSE, J2ME
       Spring, Hibernate, MySQL, GlassFish v2
       HTML, CSS, Javascript
       Prototype, Script.aculo.us, JQuery
       Direct Web Remoting (DWR)…
So, just what is Ajax?

•   “Asynchronous JavaScript and XML”
        “…group of interrelated web development techniques used for creating interactive web
        applications or rich Internet applications.” (Wikipedia, 2008)


•   Building block for “Web 2.0” applications
        Facebook, Google Mail and many more (auto-complete forms)




•   Applications can retrieve data from the server asynchronously in the background
    without interfering with the display and behaviour of the existing page
        No browser plugins (a’la Flash, Flex, SilverLight)


•   The use of JavaScript, XML, or its asynchronous use is not required…
Ajax - the old school way…
        Client


                                              Server




                        http://java.sun.com/developer/technicalArticles/J2EE/AJAX
Old school, not so cool…

• Client-side
      Browser incompatibilities (Microsoft, and then the rest of the world...)
      Long-winded
      Error prone
      Responsible for parsing return data, often XML-based
      Responsible for handling application errors (response codes?)
      Large amount of repeated “boiler plate” code


• Server-side
      Create Servlets (no abstraction, and limited chance to allow design patterns)
      Construct XML document of data
      Responsible for “flattening” Objects and Collections
      Set content-type of return data manually
      Manual error handing (convert Exceptions into response codes?)
Introducing the alternatives…

•   JavaScript Libraries/Frameworks
       dojo, JQuery, Prototype
       Greatly simplify client-side code
       Not so helpful on server-side…


•   JSP Taglibs/JSF Components
       jMaki, Ajax4jsf
       Very easy to utilise
       Limited server-side configuration (majority of focus on existing widgets and services)


•   Proxy-based Frameworks
       Direct Web Remoting (DWR), Rajax
       Best of both worlds
       Language specific on backend (Java)


•   Tip: Always new stuff coming out – check blogs and news sites...
Direct Web Remoting (DWR)
Overview

•   DWR allows easy implementation of Ajax functionality
        Homepage @ http://directwebremoting.org/
        Open source
        JavaScript “client-side”
        Java “server-side”


•   Proxy-based framework
        Client-side code can call Java server-side methods as if they were local
        JavaScript functions.
        Converts or “marshalls” parameters and return variable to/from Java/JavaScript

•   DWR generates the intermediate code (“piping” or boilerplate code)

•   Also provides Utility classes
DWR in pictures




                  Image from http://directwebremoting.org/dwr/overview/dwr
Client-side

•   Core components
        DWR JavaScript engine
        JavaScript “interface” definitions of remote methods
        JavaScript Object Notation (JSON) used instead of XML


•   Call Java methods as if local JavaScript functions
        Albeit with callbacks…


•   Hides browser incompatibilities (via “engine.js”)
        XMLHttpRequest Object
        Maps function calls to URLs


•   Converts or “marshalls” data
        Java ArrayLists into JavaScript arrays
        Java Objects into JavaScript object


•   Simplifies error-handling
        Maps Java Exceptions to JavaScript errors
Server-side

•   Core components
        DWR JAR Library
        Proxy generator
        DWRServlets


•   Easy framework configuration
        XML or Annotations (Java 5+)
        Care needed…


•   Not tied to writing Servlets
        Promotes good OO coding and design patterns


•   Simply expose (existing) Application Services
        Specify order and types of parameter
        Can return any type of Collection or Object
        Can utilise Spring, Struts, JSF…
Implementation in 5 (easy) steps…


1. Copy DWR Library files into project

2. Configure your existing framework to handle DWR requests

3. Create your Data Model (Business Objects) and Application Services

4. Inform DWR of these classes and their required exposure client-side
    1. dwr.xml configuration file
    2. Annotations (Java 5+)


5. Create your client-side functions
Handling http requests (web.xml)….


 …

     <servlet>
         <servlet-name>dwr-invoker</servlet-name>
         <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
         <init-param>
             <param-name>classes</param-name>
             <param-value>
       uk.ac.surrey.wappdev.appservices.FeedbackService,
       uk.ac.surrey.wappdev.model.FeedbackBean
             </param-value>
         </init-param>
     </servlet>

     <servlet-mapping>
         <servlet-name>dwr-invoker</servlet-name>
         <url-pattern>/dwr/*</url-pattern>
     </servlet-mapping>
     …
Create the Model (Business Objects)

package uk.ac.surrey.wappdev.model;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;

@DataTransferObject
public class FeedbackBean {

    @RemoteProperty
    private int id;
    @RemoteProperty
    private String feedbackValue;

     public FeedbackBean() {
    }

    public FeedbackBean(int id, String feedbackValue) {
        this.id = id;
        this.feedbackValue = feedbackValue;
    }

    //getter and setter defined here...
…
Create your Application Services…

package uk.ac.surrey.wappdev.appservices;

import ...

@RemoteProxy
public class FeedbackService {

      @RemoteMethod
      public List<FeedbackBean> getFeedbackAvailable() {
          List<FeedbackBean> results = new ArrayList<FeedbackBean>();

          for (int i = 0; i < 5; i++) {
              FeedbackBean fbBean = new FeedbackBean(i, "Feedback Value " + i);
              results.add(fbBean);
          }
          return results;
      }
...
}
Create your client-side functions…
                                                                                            package uk.ac.surrey.wappdev.appservices;

       <script src='dwr/interface/LocService.js'></script>                                  import ...
      <script src='dwr/engine.js'></script>
                                                                                            @RemoteProxy
                                                                                            public class FeedbackService {
      <script>
          function updateFeedback() {                                                           @RemoteMethod
              //alert("updateFeedback()");                                                      public List<FeedbackBean>
                                                                                            getFeedbackAvailable() {
                                                                                                    List<FeedbackBean> results =
                FeedbackService.getFeedbackAvailable({                                                     new ArrayList<FeedbackBean>();
                    callback:function(dataFromServer) {
                        cbUpdateFeedback(dataFromServer);                                           for (int i = 0; i < 5; i++) {
                    },                                                                                  FeedbackBean fbBean =
                                                                                                           new FeedbackBean(i, "Feedback
                    errorHandler:function(errorString, exception) {
                                                                                            Value " + i);
                        alert("Error: " + errorString);                                                 results.add(fbBean);
                    }                                                                               }
                });                                                                                 return results;
            }                                                                                   }
                                                                                            ...
                                                                                            }
            function cbUpdateFeedback(feedbackBeanList) {
                //alert("cbUpdateFeedback()");
                for (var i = 0, l = feedbackBeanList.length; i < l; i++) {

                    var option = document.createElement("option");
                    option.setAttribute("value",feedbackBeanList[i].id);

                    var optText = document.createTextNode(feedbackBeanList[i].feedbackValue);
                    option.appendChild(optText);

                    document.getElementById("feedbackEl").appendChild(option);

                }
            }
</script>
Lights, camera, action...
(oh yes, and debugging)

•   Quick demo of slide material



•   Quick look at debugging
       Client-side – Firefox’s Firebug
       Server-side – Netbeans’ debugger



•   Tip: If you want to be a professional software developer debugging
    efficiently should become as natural as breathing…
       Not emphasized enough in teaching (but this is just my opinion)
       Probably a worthwhile skill for those final year projects as well…
Real world case study... TriOpsis Ltd

 •   Highly innovative start-up company based at the Research Park (STC)
 •   Check out www.triopsis.co.uk for more information
 •   Experts in the emerging field of Visual Business Information
      • Specialising on ‘in the field’ data capture via mobile devices
      • Images and associated metadata reporting relevant to target customer
Real world case study... TriOpsis Ltd




Screenshot of TriOpsis Flagship product – the ‘Asset Manager’ (implemented by yours truly!)
And finally…
There are some disadvantages with DWR…
•   As with any framework that generates (blackbox) “piping”
        Sometimes difficult to know what is happening “in the pipe”


•   Potentially difficult to debug
        Spans across client and server domain
        Can use Netbeans debugger and FireFox’s Firebug


•   Maintaining http session information
        Hybrid of POSTed forms and Ajax


•   Can cause unexpectedly large amounts of http traffic
        Passing of complete object graphs (typically developer error ☺ )


•   Potential security implications
        Exposing incorrect methods etc.
        Easy to pass sensitive data in plaintext (passwords etc.) without knowing
Conclusions

•   We know what Ajax is…

•   We examined old school/new school approaches to implementation

•   We learned that DWR is a “proxy-based” framework
         Providing (JavaScript) client and (Java) server-side Ajax support
         Allows exposure of Java model (BOs) and services
         DWR “handles the details”..


•   We’ve seen how to implement DWR

•   We’ve had a look at an often undervalued skill – debugging

•   Seen real case study using this technology, TriOpsis, which is actively used within Industry

•   And we are always aware of potential disadvantages
         Beware of “black box” implementations…
         Security, session and http traffic
Thanks for your attention…


•   I’m happy to answer questions now or later...



•   If you want to know more about DWR or debugging ask for a lab session
       Sorry, but I can’t answer individual emails...




•   Feedback, comments, constructive criticism...

Contenu connexe

Tendances

Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsIMC Institute
 
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedJava Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedIMC Institute
 
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8Michael Miles
 
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXDrupalSib
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceParashuram N
 
Demystifying AJAX Callback Commands in Drupal 8
Demystifying AJAX Callback Commands in Drupal 8Demystifying AJAX Callback Commands in Drupal 8
Demystifying AJAX Callback Commands in Drupal 8Michael Miles
 
Demystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback CommandsDemystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback CommandsMichael Miles
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, mavenFahad Golra
 
Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8Codemotion
 
Drupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsDrupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsMichael Miles
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinSimon Gauvin
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySqlkamal kotecha
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJini Lee
 
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)Fahad Golra
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session ManagementFahad Golra
 

Tendances (20)

Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedJava Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet Advanced
 
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8
MidCamp 2016 - Demystifying AJAX Callback Commands in Drupal 8
 
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and Performance
 
Demystifying AJAX Callback Commands in Drupal 8
Demystifying AJAX Callback Commands in Drupal 8Demystifying AJAX Callback Commands in Drupal 8
Demystifying AJAX Callback Commands in Drupal 8
 
Demystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback CommandsDemystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback Commands
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8
 
Drupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commandsDrupal8Day: Demystifying Drupal 8 Ajax Callback commands
Drupal8Day: Demystifying Drupal 8 Ajax Callback commands
 
11-DWR-and-JQuery
11-DWR-and-JQuery11-DWR-and-JQuery
11-DWR-and-JQuery
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySql
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparison
 
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 

En vedette

Continuous Health
Continuous HealthContinuous Health
Continuous HealthJames Brett
 
Maria Mitchell Portfolio
Maria Mitchell PortfolioMaria Mitchell Portfolio
Maria Mitchell PortfolioMaria Mitchell
 
Jeopardy Game
Jeopardy GameJeopardy Game
Jeopardy GameKelly
 
Assignments That Matter F I N A L!
Assignments That  Matter    F I N A L!Assignments That  Matter    F I N A L!
Assignments That Matter F I N A L!Kelly
 
9782909735221 inquisiteur
9782909735221 inquisiteur9782909735221 inquisiteur
9782909735221 inquisiteursti1966
 
Classroom language
Classroom languageClassroom language
Classroom languagejopeme
 
Corso di Formazione Volontari A 08/09
Corso di Formazione Volontari A 08/09Corso di Formazione Volontari A 08/09
Corso di Formazione Volontari A 08/09Lettori Pazienti
 
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"Daniel Bryant
 
LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"
LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"
LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"Daniel Bryant
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)Daniel Bryant
 
Cap belgique-discrimination
Cap belgique-discriminationCap belgique-discrimination
Cap belgique-discriminationsti1966
 
Aout 1999
Aout 1999Aout 1999
Aout 1999sti1966
 
ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...
ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...
ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...Daniel Bryant
 
Quick Business Overview
Quick Business OverviewQuick Business Overview
Quick Business Overviewbergerteam
 
Kindle - Why are publishers fighting Amazon over prices?
Kindle - Why are publishers fighting Amazon over prices?Kindle - Why are publishers fighting Amazon over prices?
Kindle - Why are publishers fighting Amazon over prices?Armen Mardirousi
 
Innovative trends of elearning
Innovative trends of elearningInnovative trends of elearning
Innovative trends of elearningvickytg123
 
Disgrafia colombo
Disgrafia colomboDisgrafia colombo
Disgrafia colomboimartini
 

En vedette (20)

Continuous Health
Continuous HealthContinuous Health
Continuous Health
 
Weather Day 3
Weather Day 3Weather Day 3
Weather Day 3
 
Maria Mitchell Portfolio
Maria Mitchell PortfolioMaria Mitchell Portfolio
Maria Mitchell Portfolio
 
Jeopardy Game
Jeopardy GameJeopardy Game
Jeopardy Game
 
Assignments That Matter F I N A L!
Assignments That  Matter    F I N A L!Assignments That  Matter    F I N A L!
Assignments That Matter F I N A L!
 
9782909735221 inquisiteur
9782909735221 inquisiteur9782909735221 inquisiteur
9782909735221 inquisiteur
 
Classroom language
Classroom languageClassroom language
Classroom language
 
Corso di Formazione Volontari A 08/09
Corso di Formazione Volontari A 08/09Corso di Formazione Volontari A 08/09
Corso di Formazione Volontari A 08/09
 
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
LJCConf 2013 "Chuck Norris Doesn't Need DevOps"
 
LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"
LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"
LJCConf 2013 "Contributing to OpenJDK for the GitHub Generation"
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
 
Cap belgique-discrimination
Cap belgique-discriminationCap belgique-discrimination
Cap belgique-discrimination
 
Aout 1999
Aout 1999Aout 1999
Aout 1999
 
ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...
ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...
ContainerSched 2015 "Our journey to world (gifting) domination - how notonthe...
 
Quick Business Overview
Quick Business OverviewQuick Business Overview
Quick Business Overview
 
Dla Odwaznych
Dla OdwaznychDla Odwaznych
Dla Odwaznych
 
Kindle - Why are publishers fighting Amazon over prices?
Kindle - Why are publishers fighting Amazon over prices?Kindle - Why are publishers fighting Amazon over prices?
Kindle - Why are publishers fighting Amazon over prices?
 
Innovative trends of elearning
Innovative trends of elearningInnovative trends of elearning
Innovative trends of elearning
 
Cucina modello Touch di Oikos
Cucina modello Touch di OikosCucina modello Touch di Oikos
Cucina modello Touch di Oikos
 
Disgrafia colombo
Disgrafia colomboDisgrafia colombo
Disgrafia colombo
 

Similaire à DWR: Ajax made easy with Direct Web Remoting

using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'sAntônio Roberto Silva
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkIndicThreads
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Frameworkvhazrati
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & WebpackCodifly
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014hezamu
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenJoshua Long
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing ComplexityRyan Anklam
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!Sébastien Levert
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSVisual Engineering
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsSoós Gábor
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Michael Plöd
 

Similaire à DWR: Ajax made easy with Direct Web Remoting (20)

using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Intro react js
Intro react jsIntro react js
Intro react js
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJS
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 

Plus de Daniel Bryant

ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API GatewaysITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API GatewaysDaniel Bryant
 
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...Daniel Bryant
 
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"Daniel Bryant
 
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...Daniel Bryant
 
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"Daniel Bryant
 
Fall 22: "From Kubernetes to PaaS to... err, what's next"
Fall 22: "From Kubernetes to PaaS to... err, what's next"Fall 22: "From Kubernetes to PaaS to... err, what's next"
Fall 22: "From Kubernetes to PaaS to... err, what's next"Daniel Bryant
 
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...Daniel Bryant
 
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...Daniel Bryant
 
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...Daniel Bryant
 
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"Daniel Bryant
 
KubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
KubeCon EU 2022: From Kubernetes to PaaS to Err What's NextKubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
KubeCon EU 2022: From Kubernetes to PaaS to Err What's NextDaniel Bryant
 
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...Daniel Bryant
 
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"Daniel Bryant
 
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...Daniel Bryant
 
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...Daniel Bryant
 
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Daniel Bryant
 
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"Daniel Bryant
 
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...Daniel Bryant
 
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...Daniel Bryant
 
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...Daniel Bryant
 

Plus de Daniel Bryant (20)

ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API GatewaysITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
 
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
 
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
 
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
 
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
 
Fall 22: "From Kubernetes to PaaS to... err, what's next"
Fall 22: "From Kubernetes to PaaS to... err, what's next"Fall 22: "From Kubernetes to PaaS to... err, what's next"
Fall 22: "From Kubernetes to PaaS to... err, what's next"
 
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
 
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
 
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
 
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
 
KubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
KubeCon EU 2022: From Kubernetes to PaaS to Err What's NextKubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
KubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
 
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
 
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
 
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
 
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
 
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
 
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
 
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
 
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
 
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
 

DWR: Ajax made easy with Direct Web Remoting

  • 1. L2: Web Application Development Direct Web Remoting (DWR): Ajax made easy… Daniel Bryant Department of Computing, FEPS (d.bryant@surrey.ac.uk) Tai-Dev Ltd, (daniel.bryant@tai-dev.co.uk)
  • 2. Today’s roadmap... • My life story (in under 3 minutes)… • Quick review - so, what is Ajax? (Old school vs new school) • DWR Introduction Looking deeper into DWR (client-side/server-side) Implementation Demo (and debugging) • Quick case study – TriOpsis Ltd • DWR is awesome!! But are there any disadvantages? • Review
  • 3. My life story (abridged)… • Studying at Surrey for 8 years BSc Computing and IT - Placement at DTI (now called BERR, DBIS etc. etc...) MSc Internet Computing • PhD Student within the Department of Computing Argumentation “how humans reason” Software Agents “mobile and/or intelligent code” • JEE, Web 2.0, J2ME & RDBMS Consultant Working freelance for the past 5 years Started Tai-Dev Ltd 1 year ago (http://tai-dev.blog.co.uk/) J2EE, JEE 5, JSE, J2ME Spring, Hibernate, MySQL, GlassFish v2 HTML, CSS, Javascript Prototype, Script.aculo.us, JQuery Direct Web Remoting (DWR)…
  • 4. So, just what is Ajax? • “Asynchronous JavaScript and XML” “…group of interrelated web development techniques used for creating interactive web applications or rich Internet applications.” (Wikipedia, 2008) • Building block for “Web 2.0” applications Facebook, Google Mail and many more (auto-complete forms) • Applications can retrieve data from the server asynchronously in the background without interfering with the display and behaviour of the existing page No browser plugins (a’la Flash, Flex, SilverLight) • The use of JavaScript, XML, or its asynchronous use is not required…
  • 5. Ajax - the old school way… Client Server http://java.sun.com/developer/technicalArticles/J2EE/AJAX
  • 6. Old school, not so cool… • Client-side Browser incompatibilities (Microsoft, and then the rest of the world...) Long-winded Error prone Responsible for parsing return data, often XML-based Responsible for handling application errors (response codes?) Large amount of repeated “boiler plate” code • Server-side Create Servlets (no abstraction, and limited chance to allow design patterns) Construct XML document of data Responsible for “flattening” Objects and Collections Set content-type of return data manually Manual error handing (convert Exceptions into response codes?)
  • 7. Introducing the alternatives… • JavaScript Libraries/Frameworks dojo, JQuery, Prototype Greatly simplify client-side code Not so helpful on server-side… • JSP Taglibs/JSF Components jMaki, Ajax4jsf Very easy to utilise Limited server-side configuration (majority of focus on existing widgets and services) • Proxy-based Frameworks Direct Web Remoting (DWR), Rajax Best of both worlds Language specific on backend (Java) • Tip: Always new stuff coming out – check blogs and news sites...
  • 8. Direct Web Remoting (DWR) Overview • DWR allows easy implementation of Ajax functionality Homepage @ http://directwebremoting.org/ Open source JavaScript “client-side” Java “server-side” • Proxy-based framework Client-side code can call Java server-side methods as if they were local JavaScript functions. Converts or “marshalls” parameters and return variable to/from Java/JavaScript • DWR generates the intermediate code (“piping” or boilerplate code) • Also provides Utility classes
  • 9. DWR in pictures Image from http://directwebremoting.org/dwr/overview/dwr
  • 10. Client-side • Core components DWR JavaScript engine JavaScript “interface” definitions of remote methods JavaScript Object Notation (JSON) used instead of XML • Call Java methods as if local JavaScript functions Albeit with callbacks… • Hides browser incompatibilities (via “engine.js”) XMLHttpRequest Object Maps function calls to URLs • Converts or “marshalls” data Java ArrayLists into JavaScript arrays Java Objects into JavaScript object • Simplifies error-handling Maps Java Exceptions to JavaScript errors
  • 11. Server-side • Core components DWR JAR Library Proxy generator DWRServlets • Easy framework configuration XML or Annotations (Java 5+) Care needed… • Not tied to writing Servlets Promotes good OO coding and design patterns • Simply expose (existing) Application Services Specify order and types of parameter Can return any type of Collection or Object Can utilise Spring, Struts, JSF…
  • 12. Implementation in 5 (easy) steps… 1. Copy DWR Library files into project 2. Configure your existing framework to handle DWR requests 3. Create your Data Model (Business Objects) and Application Services 4. Inform DWR of these classes and their required exposure client-side 1. dwr.xml configuration file 2. Annotations (Java 5+) 5. Create your client-side functions
  • 13. Handling http requests (web.xml)…. … <servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>classes</param-name> <param-value> uk.ac.surrey.wappdev.appservices.FeedbackService, uk.ac.surrey.wappdev.model.FeedbackBean </param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> …
  • 14. Create the Model (Business Objects) package uk.ac.surrey.wappdev.model; import org.directwebremoting.annotations.DataTransferObject; import org.directwebremoting.annotations.RemoteProperty; @DataTransferObject public class FeedbackBean { @RemoteProperty private int id; @RemoteProperty private String feedbackValue; public FeedbackBean() { } public FeedbackBean(int id, String feedbackValue) { this.id = id; this.feedbackValue = feedbackValue; } //getter and setter defined here... …
  • 15. Create your Application Services… package uk.ac.surrey.wappdev.appservices; import ... @RemoteProxy public class FeedbackService { @RemoteMethod public List<FeedbackBean> getFeedbackAvailable() { List<FeedbackBean> results = new ArrayList<FeedbackBean>(); for (int i = 0; i < 5; i++) { FeedbackBean fbBean = new FeedbackBean(i, "Feedback Value " + i); results.add(fbBean); } return results; } ... }
  • 16. Create your client-side functions… package uk.ac.surrey.wappdev.appservices; <script src='dwr/interface/LocService.js'></script> import ... <script src='dwr/engine.js'></script> @RemoteProxy public class FeedbackService { <script> function updateFeedback() { @RemoteMethod //alert("updateFeedback()"); public List<FeedbackBean> getFeedbackAvailable() { List<FeedbackBean> results = FeedbackService.getFeedbackAvailable({ new ArrayList<FeedbackBean>(); callback:function(dataFromServer) { cbUpdateFeedback(dataFromServer); for (int i = 0; i < 5; i++) { }, FeedbackBean fbBean = new FeedbackBean(i, "Feedback errorHandler:function(errorString, exception) { Value " + i); alert("Error: " + errorString); results.add(fbBean); } } }); return results; } } ... } function cbUpdateFeedback(feedbackBeanList) { //alert("cbUpdateFeedback()"); for (var i = 0, l = feedbackBeanList.length; i < l; i++) { var option = document.createElement("option"); option.setAttribute("value",feedbackBeanList[i].id); var optText = document.createTextNode(feedbackBeanList[i].feedbackValue); option.appendChild(optText); document.getElementById("feedbackEl").appendChild(option); } } </script>
  • 17. Lights, camera, action... (oh yes, and debugging) • Quick demo of slide material • Quick look at debugging Client-side – Firefox’s Firebug Server-side – Netbeans’ debugger • Tip: If you want to be a professional software developer debugging efficiently should become as natural as breathing… Not emphasized enough in teaching (but this is just my opinion) Probably a worthwhile skill for those final year projects as well…
  • 18. Real world case study... TriOpsis Ltd • Highly innovative start-up company based at the Research Park (STC) • Check out www.triopsis.co.uk for more information • Experts in the emerging field of Visual Business Information • Specialising on ‘in the field’ data capture via mobile devices • Images and associated metadata reporting relevant to target customer
  • 19. Real world case study... TriOpsis Ltd Screenshot of TriOpsis Flagship product – the ‘Asset Manager’ (implemented by yours truly!)
  • 20. And finally… There are some disadvantages with DWR… • As with any framework that generates (blackbox) “piping” Sometimes difficult to know what is happening “in the pipe” • Potentially difficult to debug Spans across client and server domain Can use Netbeans debugger and FireFox’s Firebug • Maintaining http session information Hybrid of POSTed forms and Ajax • Can cause unexpectedly large amounts of http traffic Passing of complete object graphs (typically developer error ☺ ) • Potential security implications Exposing incorrect methods etc. Easy to pass sensitive data in plaintext (passwords etc.) without knowing
  • 21. Conclusions • We know what Ajax is… • We examined old school/new school approaches to implementation • We learned that DWR is a “proxy-based” framework Providing (JavaScript) client and (Java) server-side Ajax support Allows exposure of Java model (BOs) and services DWR “handles the details”.. • We’ve seen how to implement DWR • We’ve had a look at an often undervalued skill – debugging • Seen real case study using this technology, TriOpsis, which is actively used within Industry • And we are always aware of potential disadvantages Beware of “black box” implementations… Security, session and http traffic
  • 22. Thanks for your attention… • I’m happy to answer questions now or later... • If you want to know more about DWR or debugging ask for a lab session Sorry, but I can’t answer individual emails... • Feedback, comments, constructive criticism...