DWR: Direct Web Remoting Jim Kriz August 15, 2005 SARK Inc.

Slides:



Advertisements
Similar presentations
Behzad Samin 0 An End-to-End Overview of a RESTful Web Service.
Advertisements

Ajax, GreaseMonkey, and DWR
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Fawaz Ghali AJAX: Web Programming's Toy.
1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
Lecture 11 Server Side Interaction
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
6/3/2015eBiquity1 Tutorial on AJAX Anubhav Kale (akale1 AT cs DOT umbc DOT edu)
Server-Side vs. Client-Side Scripting Languages
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
Ryan Putz. Outline  What is Ajax?  Member Technologies  Methodology  When and When Not To Use  Who’s Using Ajax?  Code Examples.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Build Great Web Application 'Fast and Easy'
Ruth Betcher Ruth Christie
GIS technologies and Web Mapping Services
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
AJAX Without the “J” George Lawniczak. What is Ajax?
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Google Web Toolkit An Overview By Shauvik Roy Choudhary.
CHEF II / Sakai Architecture. CHEF II Changes uPortal replaces Jetspeed –jsr 168 portlet, servlet compliant Spring replaces Turbine component framework.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Weekend MS CS Program Internet and Web Technologies COT 5930 Web Project Development - Ajax Dr. Roy Levow, Associate Chair & Professor
Cross Site Integration “mashups” cross site scripting.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 2 – Ajax Fundamentals.
Ajax for Dynamic Web Development Gregory McChesney.
Chapter 16: Ajax-Enabled Rich Internet Applications with XML and JSON TP2543 Web Programming Mohammad Faidzul Nasrudin.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
ICM – API Server & Forms Gary Ratcliffe.
ICM – API Server Gary Ratcliffe. 2 Agenda Webinar Programme API Server Overview JSON-RPC iCM API Service API Server and Forms New services under.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Ajax! Ajax Programming Ajax! Ajax Programming. Ajax! Ajax Programming Take a look at a typical desktop application (Spreadsheet app, etc.) The program.
Ajax 101 for CF Programmers Randy Brown – Michigan State University
Ext JS - Direct Bridging The Gap A DMSBT Presentation By Timothy Chandler.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
Ajax & Client-side Dynamic Web Gunwoo Park (Undergraduate)
Web Programming Language
CSE 154 Lecture 11: AJAx.
Google Web Toolkit Tutorial
AJAX and REST.
AJAX.
Asynchronous Java script And XML Technology
Unit 6-Chapter 2 Struts.
AJAX.
CSE 154 Lecture 11: AJAx.
DWR: Direct Web Remoting
CSE 154 Lecture 22: AJAX.
JQuery with ASP.NET.
MIS Professor Sandvig MIS 424 Professor Sandvig
Presentation transcript:

DWR: Direct Web Remoting Jim Kriz August 15, 2005 SARK Inc.

What is Direct Web Remoting? DWR is AJAX and XMLHttpRequest made easy

Foundation of DWR - XMLHttpRequest APIs available in Javascript and VBScript Can transfer XML to and from the browser Allows dynamic updates of pages without refreshing the entire page l No plugins required Example: Google SuggestGoogle Suggest

Foundation of DWR - AJAX AJAX - Asynchronous JavaScript and XML HTML for presentation DOM and JavaScript for dynamic display and interaction XML and XMLHttpRequest for interchanging data with server

DWR Features Simplifies AJAX and XMLHttpRequest l APIs for calling server objects – no need to learn complex XMLHttpRequest JavaScript code Handles marshalling/unmarshalling of parameters l Can convert primitive types, and several collections & more complex types l Developer can create custom converters Provides a framework to expose Java beans as remote objects Can access beans in a users session, or new beans created in a variety of ways Simple setup Works with existing frameworks, does not replace them l No special interfaces/classes required to be implemented or extended

More Technical Features Call batching l Can send many calls in a single round-trip request l Supports call ordering Custom error handling Remoting hooks l Get notified right before or right after a call – change state of forms, etc Remoting method choice l XMLHttpRequest or IFrame Can select GET or POST for requests

Possible Uses of DWR Scrolling a map or other large image l Google Maps Google Maps Dynamic form validation Asynchronous population of lists/text Anywhere you want to update portions of a web page without affecting other content l See DWR ExamplesDWR Examples Biggest advantage to user: Web page begins to work more like desktop application

Server Side Components Code and framework to expose Java classes as RPC style calls using AJAX principles Single Servlet to accept calls from browser l Security is handled by servlet container XML configuration file l Expose individual beans, or entire packages l Works with Spring l Conversions for common types, including Java Beans (POJOs) - User-defined conversions allowed Debug mode for testing RPCs

Server Side Setup – Dwr.jar Download dwr.jar from l Place in WEB-INF/lib Updated frequently – currently on version 1.0 RC3

Server Side Setup – Web.xml Configure DWR servlet or servlets dwr-invoker DWR Servlet uk.ltd.getahead.dwr.DWRServlet dwr-invoker /dwr/*

Server Side Setup – Web.xml Servlet takes two optional init-param elements Config – points servlet to an alternate configuration file config WEB-INF/dwr-alt.xml What config file do we use? Debug – turns on/off the DWR test page debug true Do we startup in debug/test mode?

Configures Java objects to expose as RPCs Server Side Setup – dwr.xml

Client Side Components Javascript library for making remote calls l Automatically generated for exposed classes Hides XML manipulation from developer l Automatically marshalls/unmarshalls data Hides browser-specific AJAX code from developer l Concentrate on functionality, not browser compatibility Asynchronous calls to server components l Callback mechanism to allow updates to be made once reply is received

Client Component Details – Engine.js JavaScript Engine Required for any pages using DWR Included in jsp/html page: Exposes DWREngine object Handles all cross-browser issues

DWREngine - Batching Call batching - beginBatch and endBatch DWREngine.beginBatch(); ExposedJavaObject.aMethod(); ExposedJavaObject.anotherMethod(); DWREngine.endBatch(); Executes aMethod and anotherMethod in a single round-trip call to the server As with other calls, these are asynchronous

DWREngine - Call Ordering By default, all calls are asynchronous, so may not return in the order they were sent Can be altered to be synchronous DWREngine.setOrdered(true); ExposedJavaObject.aMethod(); ExposedJavaObject.anotherMethod(); This will wait for completion of aMethod before making the call to anotherMethod Can affect application performance and end-user experience

DWREngine – Remoting Hooks Hooks allow for alerts before and after remote calls Useful for changing state of form buttons, etc. DWREngine.setPreHook( function() { myForm.submitButton.disabled=true; } ); DWREngine.setPostHook(function() { myForm.submitButton.disabled=false; } ); ExposedJavaObject.aMethod();

DWREngine – Error Handling By default, errors and warnings are hidden from the user Engine includes simple message handler – uses javascript alert() function DWREngine.setErrorHandler(DWREngine.de faultMessageHandler); DWREngine.setWarningHandler(DWREngine. defaultMessageHandler); Can define custom message handlers l Write to javascript console, perhaps

DWREngine – Remoting Options Write code to gracefully fall back if javascript is not available/enabled: DWREngine.setMethod(newmethod); l newmethod should be DWREngine.XMLHttpRequest (default) or DWREngine.IFrame Select GET or POST for sending requests DWREngine.setVerb(newverb); l newverb should be GET or POST (default)

Client Component Details – Interface Dynamically-generated JavaScript for each exposed bean Required to use a particular exposed bean Included in jsp/html page: Exposes an object with the name of your Java object Methods match the server-side object

Client Component Details – Util.js General JavaScript Utilities Optional in DWR pages Included in jsp/html page: Exposes DWRUtil object

Dynamic table methods – drawTable(), addRows(), alternateRowColors() List/option manipulation – addOptions() DOM element manipulation – getText(), getValue(), getValues(), setValue(), setValues() CSS utilities A default GMail-style Page Loading message DWRUtil - Overview

Related Projects JSON-RPC-Java- TACOS (Tapestry) CFAjax (ColdFusion) AJAX.NET - interactive.de/csharpsample/default.aspxhttp://ajax.schwarz- interactive.de/csharpsample/default.aspx

JSON-RPC Overview JSON – JavaScript Object Notation l Data interchange format with bindings for C#, Java, Javascript, Perl, etc JSON-RPC – RPC protocol l Similar to XML-RPC, but uses lightweight JSON format rather than XML XMLHttpRequest l Also used by DWR

JSON-RPC Advantages JSON is far more lightweight than XML l Requests/responses travel faster over the wire Leverages J2EE security model More advanced marshalling/unmarshalling of complex data types & collections Concentrates on providing a standard wire protocol with bindings for many languages, not just Java/JavaScript l Changing server-side language does not necessitate changing client

JSON-RPC Drawbacks JSON-RPC is more complex than DWR l Steeper learning curve for developers l More client-side coding required of developer DWR project is more active l Features and fixes are being released more frequently l JSON is concentrating more on developing JavaScript APIs (catching up with DWR) No Spring integration

TACOS Overview TACOS – Tapestry Components l Remote presentation components for Tapestry framework Allows partial page updates, but returns presentation object, rather than data Provides Tree, Partial page, PartialForm, and DirtyForm components Can work without JavaScript Is in early development, but looks promising

Why We SHOULDNT Use AJAX An interesting blog entryblog Several issues highlighted: l Asynchronous nature of requests can easily lead to poorly functioning/annoying user interfaces l Difficult to measure performance l Difficult to test JavaScript, though tools are becoming available Venkman, Selenium and WaTiR VenkmanSeleniumWaTiR

Links DWR Matt Raibles Opinion - dwr_with_spring_and dwr_with_spring_and l Theres a great movie showing his usage of AJAX

Questions?