Apr 12th, 2012, 04:48 PM
populating DB using drop down menus with existing data from tables
I was wondering how I would go about it if I wanted to make my web application so that I can populate my database using drop down menus which are filled by the existing objects from the relevant table?
I am creating a delivery management spring application using hibernate for ORM. Let's say for the sake of my question that I have two tables which look like this:
¦ Delivery_ID ¦ Product ¦ Customer_ID ¦ Date ¦
¦ Customer_ID ¦ CustomerName ¦ CustomerCountry¦
(The Customer_ID is unique to a CustomerName together with a CustomerCountry)
Since the users will for example not know the *Customer_ID* I want to be able to be able to have a page where the users are able enter a new delivery by filling in the Product, CustomerName, CustomerCountry and Date. My wish is for the first three to be drop down boxes where the user chooses from existing products, names and countries with the option to add a new one if it does not exist.
I have so far created the classes for the tables and mapped them using annotations.
How do I deal with the fact that I want to add the new deliveries entering information into columns from different tables in the same view, excluding the Delivery_ID and Customer_ID? I would like for the application to automatically detect which Customer_ID the new delivery has by what Name and Country is entered (Given that combination already exists.)
Would I hard code this into my service layer or would it be something I would do in the Controller?
I realize this is a quite broad question so I don't expect any finished code for me to use (although I wouldn't say no to that ^^), just some tips on the architecture of my application.
Thank you for your time and help,
Tags for this Thread