wood burning stoves 2.0*
The moose likes Java in General and the fly likes Advice on managing objects in requests Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Advice on managing objects in requests" Watch "Advice on managing objects in requests" New topic
Author

Advice on managing objects in requests

James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Hello,

First off, sorry if this is posted in the wrong forum, couldn't decide between newbie, servlet/JSP or general

I'm looking for some advice on how I should be managing my objects via requests, I have several JSPs that deal with handling different parts of my objects, and I'm getting a bit confused as to how I should be passing them through the requests as I go between the pages

My main domain object is my "client", which looks as follows



My client has a number of "contacts" attached to it, there can be zero to unlimited of these.


My application has a structure similar to this




From the start, on my list of clients I can easily create a link called "edit" that passes the client Id as a parameter to my action and then looks up the object. I can easily switch between the client overview and client edit page by passing the client ID through the request parameter.

My problems come with dealing with contacts, I can display a list of the contacts OK as I use the client ID to look these up. but if I want to edit a contact that is where I struggle.

I pass the client ID and the contact ID through to the action, and lookup the client, but what should I do to ensure I get the right contact? What about issues with the contact becoming detached from the client? therefore I have trouble persisting?

The technologies I'm using are Stripes MVC framework, JPA, Hibernate, Spring, and JSPs

How would you implement the passing of objects? Is there some framework that would help with this, or am I just not understanding my current frameworks enough?

Thanks


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42273
    
  64
I pass the client ID and the contact ID through to the action, and lookup the client, but what should I do to ensure I get the right contact?

I'm not sure I understand the problem. Given the contactID (or maybe the combination of clientID and contactID, depending on the data model), what problem is there getting the "right" contact? The ID (or IDs) should identify the contact uniquely, no?


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Advice on managing objects in requests