struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Wade <kw...@mindspring.com>
Subject Re: [s2] select tag not setting parameter
Date Fri, 12 Oct 2007 22:15:11 GMT
According to my sniffer, what's sent on the wire looks like this:
lastName=smith&firstName=john&county=

which makes sense since the logging output of struts 2 says this:
com.opensymphony.xwork2.interceptor.ParametersInterceptor - Setting  
params county => [  ] firstName => [ john ] lastName => [ smith ]

So... county is null/empty. But why? Obviously the select tag and the  
form know that I want it to set the "county" field in my resulting  
action class.  It's handing the "lastName" and "firstName" fields  
just fine (via the textfield tags).   Am I doing something wrong in  
the select tag?  The jsp form that displays my list of counties via  
the select tag *looks* right (in that the list of counties -- all  
strings -- looks good).  But, no matter which entry (county) I select  
from the list, no county is being passed on submit.

Any ideas at all what I'm doing wrong?  This is my first attempt at  
using the select tag.  Here's my usage again:

	<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="Find" align="center" />
	</s:form>

Again, the form's select tag seems to be grabbing the entries from my  
list (a java.util.List called "counties") ok and building a correct  
looking drop-down html select element.  But I can't get the tag to  
set "county" to... well, anything at all, on submit.

BTW, I'm using 2.0.9.

Kevin



On Oct 12, 2007, at 4:55 PM, Dave Newton wrote:

> What's being sent on the wire? (Like, is there a
> "search.county" param being sent, etc.)
>
> d.
>
> --- Kevin Wade <kwade@mindspring.com> wrote:
>
>> Bump.  Any one have any ideas at all?  I'm sure I'm
>> just doing
>> something incorrect w/ the select tag but just can't
>> see it.
>>
>> Kevin
>>
>> On Oct 8, 2007, at 4:59 PM, Kevin Wade wrote:
>>
>>> 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
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message