click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sander van Grieken (JIRA)" <>
Subject [jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping
Date Wed, 29 Dec 2010 14:47:47 GMT


Sander van Grieken commented on CLK-744:

So this means everyone is forced to pass Option/Optiongroup from the DataProvider (which it
doesn't compile-time enforce by the way), and Strings to setValue() ? Feels a bit clumsy to

And if I remember correctly passing an Option to setValue() doesn't work because it gets toString-ed
to the java instance string representation '' so that
IMO is still a bug. Arg, no time today anymore, but you probably want to see a test page for

It's easily fixed by the snippet in my original bug report, whether it's a bug or not. Since
the Select class anyway does not strictly force the items in the backing list to be of any
particular type, it should either make it strict (e.g. by slapping a common interface on Option
and OptionGroup and expecting  Iterable<common interface> in DataProvider), or allow
for proper conversion/wrapping at render time.

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>                 Key: CLK-744
>                 URL:
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments:
> When calling setValue on a Select instance, it bombs out while rendering, regardless
whether a String or an Option is passed.
> Passing an Option instance causes it to be 'toString'-ed as an Object (i.e. '')
when retrieving the selected value again.
> Passing a String causes it to throw a java.lang.IllegalArgumentException: Select option
class not instance of Option or OptionGroup: java.lang.String
> at
> I have modified the render(HtmlStringBuffer buffer) method in to additionally
check for String instances, and in that case wrap it into an Option, and that works fine.
>                 if (object instanceof String) {
>                 	Option option = new Option(object);
>                 	option.render(this, buffer);
>                 } else ...
> The setValue method should probably be overridden from Field to also support the Option

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message