Thursday, November 10th, 2005

Ajax with Direct Web Remoting (DWR)

Category: Java, Toolkit

Philip McCarthy has another article over at IBM developerWorks. This time it is on Ajax with Direct Web Remoting.

Exciting as it is, adding Ajax functionality to your applications can mean a lot of hard work. In this third article in the Ajax for Javaâ„¢ developers series, Philip McCarthy shows you how to use Direct Web Remoting (DWR) to expose JavaBeans methods directly to your JavaScript code and automate the heavy-lifting of Ajax.

The article walks you through an example, a minimal model based on an online store.

Exposing Remote Calls

The magic of remoting with DWR is mainly in the XML config.

<!DOCTYPE dwr PUBLIC
  "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
  "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
  <allow>
    <create creator="new" javascript="catalog">
      <param name="class" 
        value="developerworks.ajax.store.CatalogDAO"/>
      <include method="getItem"/> 
      <include method="findItems"/> 
    </create> 
    <convert converter="bean" 
      match="developerworks.ajax.store.Item">
      <param name="include" 
        value="id,name,description,formattedPrice"/>
    </convert>
  </allow>
</dwr>

Posted by Dion Almaer at 12:03 am
2 Comments

++---
2.9 rating from 7 votes

2 Comments »

Comments feed

I don’t know…

I never feel safe exposing server-side methods to JavaScript. Unless you have a documented API for users (did this once with SOAP – don’t ask) and structure it to accept that the users will control server-side parameters, you’ve just opened up a wealth of injection and DOS opportunities.

Not saying it can’t make some cool apps, just saying you’d better do it right the first time.

Comment by Shawn — November 14, 2005

hi,
i want to know a few details from u .
1). how we can do client side validations using DWR.
2). how i can populate values in dropdowns, where i am getting values from database.

let me know these few things as soon as possible.

thanks & regards,
ramu

Comment by ramu — August 14, 2007

Leave a comment

You must be logged in to post a comment.