You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by akash agrawal <ak...@yahoo.co.uk> on 2008/06/11 21:37:45 UTC

select tag list listKey and listValue usage

Hi,

1. I have a list of objects which I use to populate select tag (using list attribute)
2. Use a property on that object for the listValue.

How do I populate listKey with the object itself?

Thx,

-Akash



      

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


Re: select tag list listKey and listValue usage

Posted by Dave Newton <ne...@yahoo.com>.
Here's a thought experiment:

If you did a "view source" on your page what do you want to appear as the value in the option tag? In other words, what would be where the "XXX" is below?

<option value="XXX">A name from the list</option>

The "only" thing HTTP will send is a string. S2's type conversion can be used to convert the string to something else (like, say, an Integer or a Long, or anything else if you have appropriate type conversion in place).

This value may be *used* to instantiate an object of the desired type, but it will be instantiated using whatever string value is sent as the value of the <select...>.

The shorter answer is "you can't do that, that's not how web apps work".

Dave

--- On Wed, 6/11/08, akash agrawal <ak...@yahoo.co.uk> wrote:
> From: akash agrawal <ak...@yahoo.co.uk>
> Subject: Re: select tag list listKey and listValue usage
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Wednesday, June 11, 2008, 3:59 PM
> In the value attribute I am expecting to see the name (name
> is a property on my bean) and I get that correctly by
> specifying listValue="name". In the listKey, I
> would like to set the object itself instead of another
> property. 
> 
> Further when this form is submitted the whole object is set
> on the action.
> 
> Does this clarify?
> 
> Thx.
> 
> 
> --- On Wed, 6/11/08, Dave Newton
> <ne...@yahoo.com> wrote:
> 
> > From: Dave Newton <ne...@yahoo.com>
> > Subject: Re: select tag list listKey and listValue
> usage
> > To: "Struts Users Mailing List"
> <us...@struts.apache.org>
> > Date: Wednesday, June 11, 2008, 12:52 PM
> > --- On Wed, 6/11/08, akash agrawal
> > <ak...@yahoo.co.uk> wrote:
> > > How do I populate listKey with the object itself?
> > 
> > What would that mean? What are you expecting to see in
> the
> > "value" attribute of the HTML
> <option...>
> > element?
> > 
> > Dave


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


RE: select tag list listKey and listValue usage

Posted by Michael Gagnon <mg...@genome.med.harvard.edu>.
I'm not sure that makes sense. At the end, the client is just getting some
html with a regular 'option' tag in it. The best you can do is set pass some
unique id for the key and then fetch the object back when the form is
submitted with the unique key

-----Original Message-----
From: akash agrawal [mailto:akash_agrawal@yahoo.co.uk] 
Sent: Wednesday, June 11, 2008 3:59 PM
To: Struts Users Mailing List
Subject: Re: select tag list listKey and listValue usage

In the value attribute I am expecting to see the name (name is a property on
my bean) and I get that correctly by specifying listValue="name". In the
listKey, I would like to set the object itself instead of another property. 

Further when this form is submitted the whole object is set on the action.

Does this clarify?

Thx.


--- On Wed, 6/11/08, Dave Newton <ne...@yahoo.com> wrote:

> From: Dave Newton <ne...@yahoo.com>
> Subject: Re: select tag list listKey and listValue usage
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Wednesday, June 11, 2008, 12:52 PM
> --- On Wed, 6/11/08, akash agrawal
> <ak...@yahoo.co.uk> wrote:
> > How do I populate listKey with the object itself?
> 
> What would that mean? What are you expecting to see in the
> "value" attribute of the HTML <option...>
> element?
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> 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




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


Re: select tag list listKey and listValue usage

Posted by akash agrawal <ak...@yahoo.co.uk>.
In the value attribute I am expecting to see the name (name is a property on my bean) and I get that correctly by specifying listValue="name". In the listKey, I would like to set the object itself instead of another property. 

Further when this form is submitted the whole object is set on the action.

Does this clarify?

Thx.


--- On Wed, 6/11/08, Dave Newton <ne...@yahoo.com> wrote:

> From: Dave Newton <ne...@yahoo.com>
> Subject: Re: select tag list listKey and listValue usage
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Wednesday, June 11, 2008, 12:52 PM
> --- On Wed, 6/11/08, akash agrawal
> <ak...@yahoo.co.uk> wrote:
> > How do I populate listKey with the object itself?
> 
> What would that mean? What are you expecting to see in the
> "value" attribute of the HTML <option...>
> element?
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> 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: select tag list listKey and listValue usage

Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 6/11/08, akash agrawal <ak...@yahoo.co.uk> wrote:
> How do I populate listKey with the object itself?

What would that mean? What are you expecting to see in the "value" attribute of the HTML <option...> element?

Dave


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