aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Is there a more elegant way to employ DWR ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Is there a more elegant way to employ DWR ?" Watch "Is there a more elegant way to employ DWR ?" New topic
Author

Is there a more elegant way to employ DWR ?

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hi.
Here is a snippet from my shopping cart code :

The shopping cart logic is usually called inside the action logic:

ShoppingCart is POJO, there is no Servlet classes dependencies.
Now I want to call the shopping cart methods using the DWR.
Here is a part of the required JavaScript:

My first obstacle was the book is a session based object, I have no way to access it at the JavaScript level.
So, I serialized the book's state into hidden input fields in the JSP and then I used :
DWRUtil.getValues(book);
But is there a more elegant way ?
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Not exactly what you are asking since you're using POJOs, but DWR calls do have access to session e.g., using WebContextFactory.get().getSession().

DWR documentation

You definitely have to make some architectural decisions if you're going to add DWR to your current system. To keep your POJOs you could make the DWR call to a class that pulls the data out of session and calls the POJO.
[ April 21, 2007: Message edited by: Carol Enderlin ]
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

So employing DWR is not a so transparent process ?
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
?
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Since it requires some architectural decisions, as you said.
 
 
subject: Is there a more elegant way to employ DWR ?
 
Similar Threads
Problem with a shopping cart application using Stripes
session tracking
Reimplementing parts of my app with DWR
session tracking
Shopping cart application using struts