Hi, on my
JSP there are three different drop down fields each for
1) dd
2) mm
3) yy
I want to populate data in each of these fields. For year field, Im successfully able to achieve it because the condition was to populate current year onwards only like for e.g. - year drop down field will have the current year say 2012 plus future 20 years data so it was easy. To achieve this what I did. I created a utility class and wrote a method which returns the system's current year then using for loop I iterate upto 20 and added to current year and put all these data into a list and returned this list on to jsp. Using <c:foreach> I started iterating and it is coming well.
Default value is 2012(current year)..
I can do the same thing for date and month drop down fields also but list will store all those objects by insertion order and my current date will be not be top of all objects. Please suggest me some collection to have my object first then other following it. For e.g Current date and month is 29th Oct, then I want first collection(for date) to store in order like 29, 30, 31, 1, 2, 3, -------28. And for month it should be like, 10, 11, 12, 1, 2, ,3,----9.
So that I can simple call these collections on JSP where user will have current date, month, year as pre-populated inside drop down fields on screen loads where he can change it also to something else.
I hope you got my point.
Secondly, creating different collections for dd, mm, and yy is fine? Is my approach okay or better approach you have? Because what I feel is that if I create 3 different then I have to put strong validations also to prevent user selecting a date like 31 Nov 2012 and submitting the form.
Please suggest