struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <newton.d...@yahoo.com>
Subject Re: select tag list listKey and listValue usage
Date Wed, 11 Jun 2008 20:09:55 GMT
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 <akash_agrawal@yahoo.co.uk> wrote:
> From: akash agrawal <akash_agrawal@yahoo.co.uk>
> Subject: Re: select tag list listKey and listValue usage
> To: "Struts Users Mailing List" <user@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
> <newton.dave@yahoo.com> wrote:
> 
> > From: Dave Newton <newton.dave@yahoo.com>
> > Subject: Re: select tag list listKey and listValue
> usage
> > To: "Struts Users Mailing List"
> <user@struts.apache.org>
> > Date: Wednesday, June 11, 2008, 12:52 PM
> > --- On Wed, 6/11/08, akash agrawal
> > <akash_agrawal@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


Mime
View raw message