You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by J J <je...@yahoo.es> on 2008/11/12 21:09:36 UTC

Problem with select

Hello,

I have this select but it is not working and I don't know what is missing:

<s:select
label="myLabel" name="returnValue" list="myList" listKey="key"
listValue="value" required="true"
onchange="document.location='myAction.action'"/>

I have an myAction an attribute called MyList which contains Objects of the same type A.
I also have an Attribute of type String in myAction called returnValue.
Objects of A type have key and value as attributes (both String).
All classes have getters and setters for their attributes.

The
problem is that when I reach the action myAction in returnValue I get
null (I have a System.out.println line just to know what it its value).
I think that I have something wrong with what I have to set in
attribute name.
Thanks in advance



      

Re: Problem with select

Posted by J J <je...@yahoo.es>.
OK that was I had to submit the form not only link with the action, thanks.




________________________________
De: Dave Newton <ne...@yahoo.com>
Para: Struts Users Mailing List <us...@struts.apache.org>
Enviado: miƩrcoles, 12 de noviembre, 2008 23:06:30
Asunto: Re: Problem with select

--- On Wed, 11/12/08, J J <je...@yahoo.es> wrote:
> in my jsp I receive correctly value and key, but I want to
> get the selected Item in the action who follows the jsp
> (myAction). I think that the value should be stored in the
> attribute name (which has to be the same type as listkey),
> but I get null in the action, I don't understand what's wrong.

What are you trying to accomplish with the "???" line:

> <s:select label="myLabel" name="returnValue"
>           list="myList" listKey="key"
>           listValue="value" required="true"
???>        onchange="document.location='myAction.action'"/>

To me that looks like if you change the select box the document will run the action--that is quite different from submitting a form.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


      

Re: Problem with select

Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 11/12/08, J J <je...@yahoo.es> wrote:
> in my jsp I receive correctly value and key, but I want to
> get the selected Item in the action who follows the jsp
> (myAction). I think that the value should be stored in the
> attribute name (which has to be the same type as listkey),
> but I get null in the action, I don't understand what's wrong.

What are you trying to accomplish with the "???" line:

> <s:select label="myLabel" name="returnValue"
>           list="myList" listKey="key"
>           listValue="value" required="true"
???>        onchange="document.location='myAction.action'"/>

To me that looks like if you change the select box the document will run the action--that is quite different from submitting a form.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with select

Posted by J J <je...@yahoo.es>.
in my jsp I receive correctly value and key, but I want to get the selected Item in the action who follows the jsp (myAction). I think that the value should be stored in the attribute name (which has to be the same type as listkey), but I get null in the action, I don't understand what's wrong.
thanks




________________________________
De: "Peterson, Ryan" <Ry...@McKesson.com>
Para: Struts Users Mailing List <us...@struts.apache.org>
Enviado: miƩrcoles, 12 de noviembre, 2008 22:46:36
Asunto: RE: Problem with select

What is the field name that you want to have returned (defined by
listKey) and what is the field name you want to display to the user
(defined by listValue).  

If they're not "key" and "value" respectively then that's why you're
getting null.  They need to be named the same as the attributes on the
object.

-----Original Message-----
From: J J [mailto:jesfalso@yahoo.es] 
Sent: Wednesday, November 12, 2008 1:10 PM
To: user@struts.apache.org
Subject: Problem with select

Hello,

I have this select but it is not working and I don't know what is
missing:

<s:select
label="myLabel" name="returnValue" list="myList" listKey="key"
listValue="value" required="true"
onchange="document.location='myAction.action'"/>

I have an myAction an attribute called MyList which contains Objects of
the same type A.
I also have an Attribute of type String in myAction called returnValue.
Objects of A type have key and value as attributes (both String).
All classes have getters and setters for their attributes.

The
problem is that when I reach the action myAction in returnValue I get
null (I have a System.out.println line just to know what it its value).
I think that I have something wrong with what I have to set in
attribute name.
Thanks in advance



      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


      

RE: Problem with select

Posted by "Peterson, Ryan" <Ry...@McKesson.com>.
What is the field name that you want to have returned (defined by
listKey) and what is the field name you want to display to the user
(defined by listValue).  

If they're not "key" and "value" respectively then that's why you're
getting null.  They need to be named the same as the attributes on the
object.

-----Original Message-----
From: J J [mailto:jesfalso@yahoo.es] 
Sent: Wednesday, November 12, 2008 1:10 PM
To: user@struts.apache.org
Subject: Problem with select

Hello,

I have this select but it is not working and I don't know what is
missing:

<s:select
label="myLabel" name="returnValue" list="myList" listKey="key"
listValue="value" required="true"
onchange="document.location='myAction.action'"/>

I have an myAction an attribute called MyList which contains Objects of
the same type A.
I also have an Attribute of type String in myAction called returnValue.
Objects of A type have key and value as attributes (both String).
All classes have getters and setters for their attributes.

The
problem is that when I reach the action myAction in returnValue I get
null (I have a System.out.println line just to know what it its value).
I think that I have something wrong with what I have to set in
attribute name.
Thanks in advance



      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org