How do I create a dropdown list and pick what to use for an id and displayValue?
I want to create a dropdown with the first item to be index=0, displayValue=Please Select then the rest to be the last 100 years.
I know I'll have the same problem when I want to create dropdowns of database objects.
Is there an easy solution?
This is what I have so far, but the id is the index.
ChoiceList years = new ChoiceList();
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
years.add("Please Select");
for (int i = 0; i <= 100; i++) {
Integer year = currentYear - i;
years.add(year);
}
I want to create a dropdown with the first item to be index=0, displayValue=Please Select then the rest to be the last 100 years.
I know I'll have the same problem when I want to create dropdowns of database objects.
Is there an easy solution?
This is what I have so far, but the id is the index.
ChoiceList years = new ChoiceList();
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
years.add("Please Select");
for (int i = 0; i <= 100; i++) {
Integer year = currentYear - i;
years.add(year);
}
DropDownChoice yearDropDown = new DropDownChoice("year", model, years);
Thanks
