You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bas Schulte <ba...@connectedcreations.nl> on 2009/05/26 16:03:30 UTC
s:select list and pre-selected item
Hi,
I'm pretty much stumped about this one. I have a list of countries
(List<Country>) that I return from my action to the view .jsp.
I can render the select list just fine, this is the outputted html:
<select name="activity.location.address.country" id="update-activity-
location_activity_location_address_country">
<option value="4121">Nederland</option>
<option value="4122">United Kingdom</option>
<option value="4123">Deutschland</option>
</select>
However, for the life of it I can't figure out how to have the country
that is associated with the current entity I'm editing (Activity)
selected, like this:
...
<option value="4122" selected>United Kingdom</option>
...
This is in my jsp:
<s:select name="activity.location.address.country"
value="%{activity.location.address.country}"
list="countries"
listKey="id"
listValue="displayLabel"></s:select>
With this, the list populates correctly, except for the ' selected'
option on the current country that is associated with the activity.
The answer no doubt lies in the 'value' attribute, I've tried this as
well:
value="%{activity.location.address.country.id}"
Didn't work either.
Can anyone point me in the right direction?
Thanks,
bas.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: s:select list and pre-selected item
Posted by Bas Schulte <ba...@connectedcreations.nl>.
We ran into an issue that will be fixed in 2.1.7:
https://issues.apache.org/struts/browse/WW-3140?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46241
#action_46241
We worked around it by not using s:select but coding a <select> using
s:iterator (the suggestion as it's outlined in the above issue also
works).
On 26 mei 2009, at 16:07, Paweł Wielgus wrote:
> Hi Bas,
> is your edited activity.location.address.country equal to 4122?
> If so it will be selected, if not than it won't be.
>
> Best greetings,
> Paweł Wielgus.
>
>
> 2009/5/26 Bas Schulte <ba...@connectedcreations.nl>:
>> Hi,
>>
>> I'm pretty much stumped about this one. I have a list of countries
>> (List<Country>) that I return from my action to the view .jsp.
>>
>> I can render the select list just fine, this is the outputted html:
>>
>> <select name="activity.location.address.country"
>> id="update-activity-location_activity_location_address_country">
>> <option value="4121">Nederland</option>
>> <option value="4122">United Kingdom</option>
>> <option value="4123">Deutschland</option>
>> </select>
>>
>> However, for the life of it I can't figure out how to have the
>> country that
>> is associated with the current entity I'm editing (Activity)
>> selected, like
>> this:
>>
>> ...
>> <option value="4122" selected>United Kingdom</option>
>> ...
>>
>> This is in my jsp:
>>
>> <s:select name="activity.location.address.country"
>> value="%{activity.location.address.country}"
>> list="countries"
>> listKey="id"
>> listValue="displayLabel"></s:select>
>>
>> With this, the list populates correctly, except for the ' selected'
>> option
>> on the current country that is associated with the activity.
>>
>> The answer no doubt lies in the 'value' attribute, I've tried this
>> as well:
>>
>> value="%{activity.location.address.country.id}"
>>
>> Didn't work either.
>>
>> Can anyone point me in the right direction?
>>
>> Thanks,
>>
>> bas.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: s:select list and pre-selected item
Posted by Paweł Wielgus <po...@gmail.com>.
Hi Bas,
is your edited activity.location.address.country equal to 4122?
If so it will be selected, if not than it won't be.
Best greetings,
Paweł Wielgus.
2009/5/26 Bas Schulte <ba...@connectedcreations.nl>:
> Hi,
>
> I'm pretty much stumped about this one. I have a list of countries
> (List<Country>) that I return from my action to the view .jsp.
>
> I can render the select list just fine, this is the outputted html:
>
> <select name="activity.location.address.country"
> id="update-activity-location_activity_location_address_country">
> <option value="4121">Nederland</option>
> <option value="4122">United Kingdom</option>
> <option value="4123">Deutschland</option>
> </select>
>
> However, for the life of it I can't figure out how to have the country that
> is associated with the current entity I'm editing (Activity) selected, like
> this:
>
> ...
> <option value="4122" selected>United Kingdom</option>
> ...
>
> This is in my jsp:
>
> <s:select name="activity.location.address.country"
> value="%{activity.location.address.country}"
> list="countries"
> listKey="id"
> listValue="displayLabel"></s:select>
>
> With this, the list populates correctly, except for the ' selected' option
> on the current country that is associated with the activity.
>
> The answer no doubt lies in the 'value' attribute, I've tried this as well:
>
> value="%{activity.location.address.country.id}"
>
> Didn't work either.
>
> Can anyone point me in the right direction?
>
> Thanks,
>
> bas.
>
>
>
>
> ---------------------------------------------------------------------
> 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