• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a more elegant way to employ DWR ?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So employing DWR is not a so transparent process ?
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since it requires some architectural decisions, as you said.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic