Struts 1.3.10

Is it possible to repopulate a List of Objects on an ActionForm upon
validation failure? If so, how?

Here's a simple example of what I'm trying:

*JSP:*
<html:select property="year" styleId="year">
    <html:optionsCollection property="yearList" />
</html:select>

*Form:*
String year;
List<Year> yearList = new ArrayList<Year>();

public String getYear() {
    return year;
}

public void setYear(String year) {
    this.year = year;
}


public List<Year> getYearList() {
    return yearList;
}

public void setYearList(List<Year> yearList) {
    this.yearList = yearList;
}


// ???
public void setYear( int index, Year year ) {
    yearList.set(index, year);
}

// ???
public Year getYear(int index) {
    int size = yearList.size();

    if ( (index + 1) > size )
    {
        for (int j = size; j < index + 1; j++)
        {
            yearList.add(j, new Year());
        }
    }
    return (Year)yearList.get(index);
}

Reply via email to