Since folks in this group have a high appreciation of separating business
logic from presentation. I want to ask about a common usage pattern that
comes up in web applications and seek advice on a better way to go about
things.

Imagine you have a list orders page which lists orders ... you then click on
an order and it brings you to a "edit order" page where you can see the
details about the order and the detail items for the order. You can delete
detail items from the order.

My questions relate to when, where and how, you gain access to the "order"
object. The business object that represents your order.

Currently I have this structured such that when you see a list of orders on
the list order page you see a hyperlink who's url encodes an OrderID and
this url goes to a controller jsp page. In this controller jsp page I look
up the order based on the OrderID and fetch an Order object. I then use
request dispatcher to put this order object in the request and forward to a
page that presents the order and it's detail information to the user.

The problem for me was when I started to think about what would happen after
I've deleted my order items. When I do this I shouldn't have to refetch
anything from the database since what's in memory will be kept in sync with
what's in the database. However, after I've deleted my order items I will
want to refresh the page and hence I will need all the Order information to
draw the page.

If I don't keep the object in the session in this scenario how do I get the
order from the page where I viewed it to make the change to the same page
after I've deleted an order item. I will delete an order item by selecting
checkboxes for each other item and pressing a delete button. So upon
submitting this form I then lose the reference to my Order unless it's in
the session. I had the Order when I layed out the view page but when you
submit the form over to another "controller" page you've lost the Order
reference all together. So you had it as a request attribute before but now
it's gone because it's a new request.

My question is after the action to the form that handles the deletions of
the detail item is processed how then can I gain access to my "Order" object
so that I can show it's newly updated details again.

Can somebody propose ways of gaining access to the Order object again
without cluttering up the session with it? Right now I changed my code to
eliminate the controller so that when you see a list of orders the page that
views the orders simply will have to do the fetch from the database based on
the OrderID encoded in the URL to get here in the first place. ie. the
controller that took care of the delete will dispatch back to the view page
when it's finished. So it's expected that any page that leads to this view
order page will add the OrderID in the URL and a fetch will occur. I don't
like having to structure it this way.

There aren't any Form bean objects in this scenario what gets displayed is
directly from the Order object that represents the Data from the "object
graph" in the database.

I want to understand if it's possible to keep the Order object around in the
request that's chained so that it's available when I come back to the view
order page. I don't think it is and I think I'm forced to keep it in the
session with this model2 style architecture arrangement.






---
Robert Nicholson
Email: [EMAIL PROTECTED]
AOL  : rydmerlin

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to