• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Someone Must Have an Example Like This!

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you haven't checked out Apache Struts that would be a good starting place.
Apache Struts
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bruno Collins
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic