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 DWR Object binding 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 "DWR Object binding" Watch "DWR Object binding" New topic
Author

DWR Object binding

Daniel Bryant
Ranch Hand

Joined: Jul 15, 2006
Posts: 54
Hi all,

I wonder if anyone can help with a conceptual problem I'm having with DWR? Where/how are my server-side objects which DWR calls methods on bound? Are these objects bound to a user http session?

I understand that DWR uses a main servlet that is used to route client-side method calls to appropriate server-side classes and methods, but how are the objects stored (i.e. how are they scoped, session or context etc?), and when are the server-side classes that I have programmed instantiated and when are they eligible for garbage collection?

For anyone that wants any context I am trying to include user authentication in each of my DWR server class constructors, but I need to be sure that each user will have their own instance of the server side class and not share them (because each user will have different privileges). My experiments have so far proved confusing...

Best wishes,

Daniel


SCJP 1.4,<br />SCJD (URLyBird 1.2.1, JDK 5.0)
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
By default no, they are not in session scope.

DWR Documentation on creators: includes description of the optional scope attribute.

The scope attribute is largely the same as the scope attribute as defined by the servlet spec. It allows you to specify what a bean is available to. The options are "application", "session", "request" and "page". These values should be familiar to Servlet and JSP developers.

The scope attribute is optional. It defaults to "page".
Daniel Bryant
Ranch Hand

Joined: Jul 15, 2006
Posts: 54
Hi Carol,

Many thanks - now I remember reading this page when I was first learning about DWR, but it completely escaped me!! Now I have set each of my bean creators scope attribute to session in the dwr.xml config file and everything is behaving as expected.

Your pointer to the documentation was great, and very much appreciated.

Best wishes,

Daniel
[ November 19, 2007: Message edited by: Daniel Bryant ]
 
wood burning stoves
 
subject: DWR Object binding
 
Similar Threads
How to access session and context in simple utility class
Ajax and struts integration
HttpSessionBindingListener question
Reimplementing parts of my app with DWR
Javascript Variable to POJO using DWR