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 
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

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek