You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Wade <kw...@mindspring.com> on 2007/10/08 22:59:26 UTC
[s2] select tag not setting parameter
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
Re: [s2] select tag not setting parameter
Posted by Marcos Hernandez <ma...@gmail.com>.
You're welcome. I think too that the documentation is lacking of some
detailed examples, but you could contribute with a comment, now that you
know a little more. Go ahead, you are part of the community too ;-)
http://cwiki.apache.org/confluence/display/WW/select
On 10/15/07, Kevin Wade <kw...@mindspring.com> wrote:
>
> You, Marcos, (and Laurie) were right: there was not a full list of
> values aside from the county names in the list. Each entry in the
> list looked something like this:
> <option value="">ORANGE</option>
>
> So the option value was always empty. The trick for me was to set
> the listKey parameter to "name", which contained the name of the
> county (which i also use for listValue). Frankly, I guess I just
> didn't understand the documentation -- and what listKey and listValue
> meant and did in this context. I didn't grok it at first.
>
> As always, many thanks to the struts 2 community for pointing me in
> the right direction.
>
> Kevin
>
> On Oct 12, 2007, at 7:03 PM, Marcos Hernandez wrote:
>
> > Just as a debug thought: what happens when you fill the list
> > parameter with
> > a couple of counties/value pairs by hand?
> >
> > On the other hand, does the generated HTML have a full list of
> > values aside
> > of the counties name list you are looking in the drop-down box?
> >
> > On 10/12/07, Kevin Wade <kw...@mindspring.com> wrote:
> >>
> >> 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 <kw...@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
> >>>
> >>
> >>
> >
> >
> > --
> > - Marcos H.
> > ________________________________________
> > You must be the change you wish to see in the world
> > ~ Gandhi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
- Marcos H.
________________________________________
You must be the change you wish to see in the world
~ Gandhi
Re: [s2] select tag not setting parameter
Posted by Kevin Wade <kw...@mindspring.com>.
You, Marcos, (and Laurie) were right: there was not a full list of
values aside from the county names in the list. Each entry in the
list looked something like this:
<option value="">ORANGE</option>
So the option value was always empty. The trick for me was to set
the listKey parameter to "name", which contained the name of the
county (which i also use for listValue). Frankly, I guess I just
didn't understand the documentation -- and what listKey and listValue
meant and did in this context. I didn't grok it at first.
As always, many thanks to the struts 2 community for pointing me in
the right direction.
Kevin
On Oct 12, 2007, at 7:03 PM, Marcos Hernandez wrote:
> Just as a debug thought: what happens when you fill the list
> parameter with
> a couple of counties/value pairs by hand?
>
> On the other hand, does the generated HTML have a full list of
> values aside
> of the counties name list you are looking in the drop-down box?
>
> On 10/12/07, Kevin Wade <kw...@mindspring.com> wrote:
>>
>> 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 <kw...@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
>>>
>>
>>
>
>
> --
> - Marcos H.
> ________________________________________
> You must be the change you wish to see in the world
> ~ Gandhi
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [s2] select tag not setting parameter
Posted by Marcos Hernandez <ma...@gmail.com>.
Just as a debug thought: what happens when you fill the list parameter with
a couple of counties/value pairs by hand?
On the other hand, does the generated HTML have a full list of values aside
of the counties name list you are looking in the drop-down box?
On 10/12/07, Kevin Wade <kw...@mindspring.com> wrote:
>
> 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 <kw...@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
> >
>
>
--
- Marcos H.
________________________________________
You must be the change you wish to see in the world
~ Gandhi
Re: [s2] select tag not setting parameter
Posted by Laurie Harper <la...@holoweb.net>.
What does the generated HTML look like? Perhaps the county objects don't
have a value for 'id'?
L.
Kevin Wade wrote:
> 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 <kw...@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
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [s2] select tag not setting parameter
Posted by Kevin Wade <kw...@mindspring.com>.
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 <kw...@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
>
Re: [s2] select tag not setting parameter
Posted by Dave Newton <ne...@yahoo.com>.
What's being sent on the wire? (Like, is there a
"search.county" param being sent, etc.)
d.
--- Kevin Wade <kw...@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
Re: [s2] select tag not setting parameter
Posted by Kevin Wade <kw...@mindspring.com>.
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