Search code examples
javajspstruts

Struts 1.2: html:options does not find a collection from a bean


I have a Struts page which displays the following in a form in my JSP:

            <html:select property="value">
                <html:options collection="valueNext"/> 
            </html:select>

In the Java form, the getters both exist:

    public AValue getValue() {
        return value;
    }

    public List<AValue> getValueNext() {
        return value.next();
    }

Yet, when I try to display the page, I always have an error message telling me the following:

Cannot find bean under name valueNext

I do not understand why Struts would find the value and not valueNext (yes, I have removed the html:options lines, and it works).

I am quite new to Struts, but it appears to me that both are in the same scope. Can somebody enlighten me?


Solution

  • I finally found it (thanks to the help of another contributor).

    I am not using the right tag: html:options is to use when you invoke another bean.

    To invoke a property of your form, I should use html:optionsCollection instead. The following JSP works just fine:

            <html:select property="value">
                <html:optionsCollection property="valueNext"/> 
            </html:select>
    

    (Struts documentation: html:options and html:optionsCollection)