JavaScript
  Home arrow JavaScript arrow Page 3 - Intergrate DWR into Your Java Web Applicat...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Intergrate DWR into Your Java Web Application
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2008-07-24

    Table of Contents:
  • Intergrate DWR into Your Java Web Application
  • Configuring the Application
  • Direct Web Remoting (DWR) for Java Jocks
  • Direct Web Remoting (DWR) for Java Jocks continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Intergrate DWR into Your Java Web Application - Direct Web Remoting (DWR) for Java Jocks


    (Page 3 of 4 )

    You may have to restart the Java web application for the servlet container to create a new instance of this DWR-related servlet.

    You also have to create a simple XML file declaring the Java classes that you want to use from your client-side JavaScript code. Don’t worry, I’ll show you how to use the JavaScript objects that are bound to Java classes shortly! The file is named dwr.xml. Place this XML file in /WEB-INF/:

      <dwr>
         
    <allow>
             
    <create creator="new" javascript="JsDate">
                 
    <param name="class" value="java.util.Date"/>
             
    </create>
             
    <create creator="new" javascript="JsBikeBean">
                 
    <param name="class" value="com.parkerriver.BikeBean"/>
              </create>
          </allow>
      </dwr>

    This XML states that the client-side JavaScript can use two Java classes remotely. The JavaScript objects that bind the client-side code remotely to the Java classes are namedJsDateandJsBikeBean. As part of the server-side preparations, you must have already developed the Java class
    com.parkerriver.BikeBeanand installed it in your application.java.util.Dateis part of the Java software development kit; it’s not your own custom class.Date is already available as part of the Java virtual machine your server component is using.

    TheBikeBeanclass file is typically stored in /WEB-INF/classes, as in /WEB-INF/classes/com/parkerriver/BikeBean.class.

    This XML file binds the two JavaScript names to theDateandBikeBeanobjects, so that these objects are available to use in your client-side JavaScript. This means that JavaScript code can call all the public methods of these Java objects. But how is the JavaScript in the local web page connected to the remote Java instances running on the server? Figure 5-1 shows in general terms the path a JavaScript method call takes in DWR’s form of web remoting.

    The web page that will use DWR contains thesescripttags, which connect the JavaScript code via the DWR servlet to the server code:

      <script type="text/javascript" src=
             
    "/[name of web app]/dwr/interface/JsBean.js">
      </script>
      <script type="text/javascript" src=
              "/[name of web app]/dwr/interface/JsDate.js">
      </script>

    More JavaScript Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Ajax Hacks," published by O'Reilly. We...
     

    Buy this book now. This article is excerpted from Hack 42 of the book Ajax Hacks, written by Bruce W. Perry (O'Reilly; ISBN: 0596101694). Check it out today at your favorite bookstore. Buy this book now.

    JAVASCRIPT ARTICLES

    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...
    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...


     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT