I'm having difficulty with a struts 2 form (jsp) that includes the use of a select tag. In short, I can't seem to get the select tag to set the parameter when submitted.

Here's the scenario. My form (for searching by last name, first name, and "county" fields) looks like this:

        <s:form action="search.action">
                <s:textfield key="search.lastName" name="lastName" />
                <s:textfield key="search.firstName" name="firstName"/>
                <s:select key="search.county"
                name="county"
                list="counties"
                listKey="id"
                listValue="name"
                size="1"
                />
                <s:submit value="Search" align="center" />
        </s:form>

In the calling action, there is a List called "counties" with a getCounties() method. So, the input form looks right. There is a nice drop-down box w/ a long list of counties. So far, so good.

But, when I submit the form (e.g. first name = "john", last name = "smith", county chosen from select drop-down list = "orange") I get nothing in the "county" field of the "search" action. "lastName" looks fine. "firstName" is fine. But, regardless of which item I select in the list of counties, the county parameter doesn't get set. I definitely have setters for firstName, lastName, and county in the search action:

        public void setCounty(String county) {
                this.county = county;
        }

In fact, here's a debug message from struts2 showing what the ParametersInterceptor is actually setting:

DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor - Setting params county => [ ] firstName => [ john ] lastName => [ smith ]

I can't figure out what I'm doing wrong that causes county to be empty. Is it something I'm doing incorrectly with the List?

kwade

Reply via email to