You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2016/03/09 07:57:54 UTC

Re: Problem using TypeConverters with SelectTag

Chris

Isn't it the same issue https://issues.apache.org/jira/browse/WW-3936 ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2015-04-30 16:43 GMT+02:00 CRANFORD, CHRIS <Ch...@setech.com>:
> Honestly, if a converter is going to be used when an <option/> tag is rendered, the <select/> tag should use the same logic for determining the selected value from the value stack.  It's prudent these two tags act unanimously on the data rather than opposing one another as they do now.
>
> Let us assume we have a database record that has a composite key.  One might create your list of values in the action as follows:
>
> public class RecordPk {
>   private Long field1;
>   private Long field2;
> }
>
> public class MyAction {
>   private Map<RecordPk, String> choices = new LinkedHashMap<RecordPk, String>();
>   private RecordPk selection;
> }
>
> <s:select name="selection" list="choices" />
>
> Using a StrutsTypeConverter I would see:
>
> <select name="selection">
>   <option value="1-29393">My Label</option>
>   <option value="3-39949">Another Label</option>
> </select>
>
> The problem is that the type converter is applied when creating the options and when the data is submitted, but the select never defaults the selected choice if a selection was initially set in the view model or when the action returns the user to input after a validation failure; thus losing any value the user had previously selected.
>
> I don't see this necessarily as a specific use case but just someone trying to use the technology as it was intended imo.
>
> -----Original Message-----
> From: Lukasz Lenart [mailto:lukaszlenart@apache.org]
> Sent: Thursday, April 30, 2015 8:30 AM
> To: Struts Users Mailing List
> Subject: Re: Problem using TypeConverters with SelectTag
>
> 2015-04-30 15:22 GMT+02:00 CRANFORD, CHRIS <Ch...@setech.com>:
>> Was this part of the fix in WW-4427?
>
> Rather unrelated to your problem as tags don't use context to store values. I'm still thinking if your solution is right, I mean common to be used by any other or rather is your specific use case.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> Email secured by Check Point

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