This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
jQuery in Action, 2nd edition
 
subject: Is there a more elegant way to employ DWR ?
 
Similar Threads
Shopping cart application using struts
session tracking
session tracking
Problem with a shopping cart application using Stripes
Reimplementing parts of my app with DWR