Every system needs this but I just can't find a good example. I want to be able to maintain a table with the following or similar screen flow. (Let's take a Customer table as the example.) Step:1) Present a list of Customers (Id, Name, Suburb) with a link to View Edit or Delete. At the bottom of the list there would be an Add button. Step:2) When a link is clicked for a Customer, a second screen is displayed based upon the link. i.e. View - show all customer fields (no data entry allowed). Edit - show existing fields & values and allow editing. Delete - show all fields (protected) with an Are you sure Y/N dialogue. Add - initialise field with default values and allow entry. There would be a button to Cancel and one to Process. The Cancel button would go back to the List (1) and the Process button would validate the fields and redisplay (2) with appropriate messages should there be errors. Step:3) When there were no errors and the mode is Add/Edit/Delete the table would be updated accordingly and a final screen displayed confirming all was OK. For a View just go back to the list. My approach (MVC) is: 1 servlet CustomerMaint which does all the flow control & database access. It would use 2 beans one to hold the list of Customers and a second to hold the details of the chosen customer. The servlet would forward to three jsp pages a) CustomerList b) CustomerMaint c) UpdateOk. I am open to suggestions & recommendations.
Was there something wrong with your original post? If you didn't get the answer(s) that you wanted, you can always reply to your own thread with a follow-up question and it'll get bumped to the top of the discussion list so it'll be noticed again. Frankly, I thought you got some decent advice from the first post but, if you needed something else, write a follow-up and clarify. Corey
When you are new, it is sometimes hard to guage why after a few days you haven't got a response especially when everyone else has. I reposted with a more descriptive subject hoping for better luck. I was unaware of the reply to oneself method. Agreed the replies I eventually got were great. Thanks everyone.
Hi, We do that with two servlets and two jsp pages. One for the customer list and one for the customer detail. -----CustomerListServlet---- actionId="display" means query for data and forward to jsp. actionId="delete" means delete requested customer(s) and redirect to URL for CustomerListServlet with actionId "display". ----- customer_list.jsp ----- View link - URL to CustomerDetailServlet with actionId="display", pageMode="view", customerId=... Edit link - URL to CustomerDetailServlet with actionId="display", pageMode="edit", customerId=... Delete button - Submit with actionId="delete", pageMode="view", list of customers to delete. Add link - URL to AddCustomerServlet with actionId="display" and customerId=(null). ---------CustomerDetailServlet------------ actionId="display", customerId not null, means query for the customer data and forward to the jsp using the pageMode specified in the request. actionId="display, customerId null, means create a default customer bean and forward to the jsp using pageMode="edit". actionId="save", valid customer information, means save the update and Redirect to a URL for the CustomerDetailServlet with actionId="display", pageMode="view", customerId=...
------customer_detail.jsp------------- fields are either input or plain html based on the pageMode String or "edit" or "view". Save button - Submit with actionId="save", list of data to save. Button does not show for "view" mode. Cancel button - URL for CustomerListServlet with actionId="display". ------------------------------------ Things I don't like about this approach. --Query for the data repeatedly, evey time a page loads or reloads. However, it keeps the application stateless and the data "fresher". If your database server performance can keep up... --Lots of servlets with similar code. An abstract servlet class does help keep the duplicate code down to a dull roar, but the servlets end up being very similar. Because of this I believe Struts is a good suggestion.