tags:

views:

49

answers:

1

in my ApplicationBean1.java class I have an Option[] attribute years and a filling method:

public void buildYearOptions(){
    int initialYear = 1900;
    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    int i = 0;
    for (int y = initialYear; y< currentYear; y++){
        Option op = new Option(y, Integer.toString(y));
        years[i] = op;
        i++;   
    }     
 }

And this is my jsp page using icefaces:

<ice:selectOneMenu id="selectOneYearMenu" partialSubmit="true"
    style="height: 24px; left: 238px; top: 94px; position: absolute; width: 72px;visibility: visible;"
    visible="true">
    <f:selectItems id="selectOneMenuYearItems" value="#{ApplicationBean1.years}"/>
</ice:selectOneMenu>

My problem is that the years from 1900 to currentyear(2010) are not showing up in the dropDownList (selectOneMenu).

Aan someone help me figure this out?

+1  A: 

I don't do IceFaces, so it might do things differently I am not aware of, but you normally feed the f:selectItems with a SelectItem[], List<SelectItem> or a Map<Object, Object>, not with an Option[] or whatever type it is.

This should work:

private List<SelectItem> years; // +getter.

public void buildYearOptions() {
    final int initialYear = 1900;
    final int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    for (int year = initialYear; year < currentYear; year++) {
        years.add(new SelectItem(year, String.valueOf(year)));
    }     
}

If it still doesn't give anything, then you're likely calling buildYearOptions() at the wrong moment or probably not calling it at all.

BalusC
Thanks man for your answer it really helped. Apparently in Icefaces, you cannot use the interface List , it only worked greatly when my field was with type ArrayList<SelectItem>:private ArrayList<SelectItem> years;
Saher