struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Sayre" <richardsa...@gmail.com>
Subject Re: s:select and pre-selection
Date Fri, 29 Feb 2008 13:36:19 GMT
I have a select that populates with a int,string id/value combo.  To
get the s:select to select the proper option I had to crate another
value in my action (int myId).  This would be set to the id of the
option to select.  Then I had to set the name attribute of my select
to myId (name="myId").

On Fri, Feb 29, 2008 at 5:04 AM, Daniel Baldes <db@open.ch> wrote:
> Hi,
>
>  I have a select box:
>
>  <s:select name="user.property"
>            list="availableObjects" listKey="id" listValue="name" />
>
>  "availableObjects" is a list of objects having an id and a name
>  property, where id is of type "long". "user.property" is 'converted' to
>  its id (as String)  by a type converter.
>
>  Now, setting user.property works well with this, but the current value
>  is not pre-selected when I load the form. When I show user.property in a
>  textfield, the correct ID is displayed (the id of the option which
>  should be pre-selected).
>
>  I found a hint in the s:select documentation, which says that for
>  OGNL-generated maps, the type of the key-attribute must be the same as
>  the type of the listKey property in order to match. So I implemented
>  "getIdAsString()" and used listKey="idAsString", but it doesn't work either.
>
>  What am I doing wrong here?
>
>  (I am using struts 2.0.11)
>
>  Any help or hint will be appreciated.
>
>  Thanks in advance,
>
>  Daniel
>
>  ---------------------------------------------------------------------
>  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


Mime
View raw message