Hi all, can you suggest some good validation technique for the following prob: say if there are 3 combo,continent,country,state.The user selects any values in the 3 combo.Clicks submit. After submission,i have to display data . If particular state is not in the particular country,or if he selects all states,i have to display countries present in the continent and countries not present in the continent,like that. Am new to java. any suggestion would be nice.
Force the user to select continent first, then country, then state/county/province/region or whatever. When continent is selected, either submit automatically or (best practice re usability) force the user to press a submit button. Populate the country list box with only countries appropriate to the selected continent. When a country is selected repeat for states. The most effective way to store these continent/country/state relationships is probably in a relational database on the server.
Allow the user to select what they want in the 3 boxes and check that the 3 selections are a valid combination against the relationships stored in your database, i.e. is country in continent; is state in country?
Do these suggestions help you to decide how you want to handle this?
Joined: Aug 25, 2004
Julian, Your suggestions really gave me some good ideas of how to do things. But,what if i am not using a database,say am reading it from some file and populating it in some objects. I have all states in one object,all continent in one object and all countries in one object. How to do the jsp validation? How to display them in jsp? Any code sample would be more helpful. Thanks in advance.
Joined: Aug 02, 2004
I'm not going to write your code for you, and it's unlikely you'll find anyone else to do that on this site either. I am, however, prepared to help you with the design of your application and point you in the right direction as to how to code it.
You need to know which countries belong to each continent and which states belong to each country. It's no good having an object containing all the continents, one containing all the countries and a third containing all the states with no relationship between them. Do you see what I mean?
If you're still not sure, perhaps you could post a small fragment of your code (using the UBB CODE tags) so that I can see what you're doing.
Joined: Aug 25, 2004
Hi Jules, Thanks for your tip. My sample code is: <select name="state"> <% ArrayList stateAl=(ArrayList)session.getAttribute("State"); int size=stateAl.size();