Professional Documents
Culture Documents
Ajax Frameworks
Ajax Frameworks
XMLHttpRequest
iFrame 4
on Rails, etc.
multiple sources
XMLHttpRequest
Easy to use
> It is just a matter of having them in the root directory of your
Tool support
> IDE's will support them in time
Most prominent and comprehensive Gaining a leadership in this space Major industry support (Sun, IBM) http://dojotoolkit.com/
Prototype
> Used by other toolkit libaries > http://prototype.conio.net/
Ext JS
> Gaining popularity > http://extjs.com/
10
Rico
> Built on Prototype > Rich AJAX components and effects > http://openrico.org/
DHTML Goodies
> Various DHTML and AJAX scripts > http://www.dhtmlgoodies.com/
11
Dojo Toolkit
14
dojo.io.bind()
var sampleFormNode = document.getElementById("formToSubmit"); dojo.io.bind({ url: "http://foo.bar.com/sampleData.js", load: function(type, evaldObj){ // hide the form when we hear back that it submitted successfully sampleFormNode.style.display = "none"; }, backButton: function(){ // ...and then when the user hits "back", re-show the form sampleFormNode.style.display = ""; }, formNode: sampleFormNode });
source: dojotoolkit.org
15
dojo.event.connect()
window.onload = function () { var link = document.getElementById("mylink"); // myHandler event handler is registered for the // "onclick" event of mylink node. dojo.event.connect(link, "onclick", myHandler);
// Define an event handler named as myHandler function myHandler(evt) { alert("myHandler: invoked - this is my named event handler"); } </script> <a href="#" id="mylink">Click Me</a>
16
17
18
Proxy
Skeleton
Framework runtime
iFrame
20
Why DWR?
What happens if you have several methods in a class on the server that you want to invoke from the browser?
> Each of these methods need to be addressable via URI
whether you are using XMLHttpRequest directory or clientside only toolkit such as Dojo or Prototype > You would have to map parameters and return values to HTML input form parameters and responses yourself
DWR provides a client/server framework that addresses these problems DWR comes with some JavaScript utility functions
21
22
JavaScript running in the browser that sends requests and can dynamically update the webpage
> DWR framework handles XMLHttpRequest handling
source: http://getahead.ltd.uk/dwr
23
conventional RPC/RMI like code, which is much more intuitive than writing raw JavaScript code
The generated JavaScript class handles remoting details between the browser and the backend server
> Handles asynchronous communication via XMLHttpRequest -
Invokes the callback function in the JavaScript > You provide the callback function as additional parameter > DWR converts all the parameters and return values between client side Javascript and backend Java
24
26
However, these widgets use different syntax and different data model
> There is a need for a common programming model and
common data model for using widgets from multiple AJAX toolkits and frameworks
28
Origins of jMaki?
j is for JavaScript technology Maki == to wrap in Japanese Started as a way of wrapping JavaScript technology functionality
> Take widgets from many popular AJAX toolkits and
29
jMaki Features
Widgets from popular toolkits
> Dojo, Yahoo, Script.aculo.us, Spry, Google
Make JavaScript technology accessible to Java technology, Phobos, PHP and Ruby Publish and subscribe event model XmlHttpProxy
> Allows access to services not in the web app domain
Future Protection
> Unified data model for widgets from different toolkits
30
31
33
What is GWT?
Java software development framework that makes writing AJAX applications easy Let you develop and debug AJAX applications in the Java language using the Java development tools of your choice
> NetBeans or Eclipse
Provides Java-to-JavaScript compiler and a special web browser that helps you debug your GWT applications
> When you deploy your application to production, the compiler
35
Virtual Machine (JVM) > You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Java's debugging facilities
Web mode
> Your application is run as pure JavaScript and HTML,
compiled from your original Java source code with the GWT Java-to-JavaScript compiler > When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application 36
Why GWT?
No need to learn/use JavaScript language
> Leverage Java programming knowledge you already have
38
Why GWT?
Leverage various tools of Java programming language for writing/debugging/testing
> For example, NetBeans or Eclipse
JUnit integration
> GWT's direct integration with JUnit lets you unit test both in a
debugger and in a browser and you can even unit test asynchronous RPCs
Internationalization
> GWT internationalization support provides a variety of
Demo: GWTHello
Build and run GWTHello sample application from GWT hands-on lab in
> Hosted mode (Debug project) > Web mode
41
Show how to invoke JavaScript code from Java code and vice versa Show how to associate a CSS style items to a GWT widget
42
NetBeans Visual Web Pack (and other JSF-aware IDE's) to build AJAX applications
community
44
Open-Source Implementations
Woodstock AJAX-enabled JSF components (opensource)
> https://woodstock.dev.java.net/index.html
ICEfaces
> http://www.icefaces.org/main/home/index.jsp
ajax4jsf
> Can add AJAX capability to existing applications > https://ajax4jsf.dev.java.net/
45
The response contains markup for the whole page not just for the target portlet Will be addressed in JSR 286
53
55
57
Echo2
> http://www.nextapp.com/platform/echo2/echo/
Wicket
> http://wicket.sourceforge.net/
Ruby on Rails
> http://www.rubyonrails.org/
58
an JSF-enabled IDE such as Visual Web Pack of NetBeans > If you are not ready to commit yourself to JSF component solutions yet, use jMaki > If you want to have total control on the client side JavaScript coding, use Dojo toolkit > If you already have Swing apps that you want to expose as AJAX-fied Web apps or if you do not want to deal with JavaScript coding, use GWT
61
exposed as RMI calls on the client with AJAX behavior, use DWR > If you are already using a particular Web application framework for building majority of your web application and the framework has AJAX extension, use it
62
So What Should I Use? If you want use Scripting Language as a Main enabler
Use Ruby on Rails or Phobos or Grails
> > > >
Leverage agile development of scripting Leverage the power of Java platform MVC based Multiple scripting languages
63