You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Sander van Grieken (JIRA)" <ji...@apache.org> on 2010/12/29 12:17:57 UTC

[jira] Created: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Select control's setValue is not usable due to insufficient wrapping
--------------------------------------------------------------------

                 Key: CLK-744
                 URL: https://issues.apache.org/jira/browse/CLK-744
             Project: Click
          Issue Type: Bug
          Components: core
    Affects Versions: 2.3.0-M1, 2.2.0
            Reporter: Sander van Grieken


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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)

I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 ...


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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12975773#action_12975773 ] 

Bob Schellink commented on CLK-744:
-----------------------------------

Don't think ithis s a bug. Select#setDataProvider Javadoc does mention passing in Options/OptionGroups, not Strings.

http://click.apache.org/docs/click-api/org/apache/click/control/Select.html#setDataProvider(org.apache.click.dataprovider.DataProvider)

Changing to Option, it works for me.

CLK-745 looks like a bug though

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12975765#action_12975765 ] 

Bob Schellink commented on CLK-744:
-----------------------------------

Setting a String value for Select works fine for me.  Can you provide a test page showing the issue?

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Sander van Grieken (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12975788#action_12975788 ] 

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 me.

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

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: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Sander van Grieken (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979316#action_12979316 ] 

Sander van Grieken commented on CLK-744:
----------------------------------------

"How will the label be rendered? It will depend on how Select interprets it."

Just like the Option(String) constructor interprets it? I don't see the ambiguity.. Select can only interpret a String in one way, no? 

If I look at AWT for example, the combobox accepts just strings as listelements just fine. The label/name paradigm is basically a low-level technical construct for uniquely identifying selected item(s) across HTTP roundtrips. This is something a high-level UI kit like click should transparently provide, if not explicitly specified by the developer. 

One could then also check all added strings for uniqueness (or illegal characters), and warn or throw an exception when not all Strings are suitable for autowrapping.

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Updated: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Sander van Grieken (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sander van Grieken updated CLK-744:
-----------------------------------

    Attachment: SelectTestPage.java

here you go.

code also applies to bug #745


> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Updated: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Sander van Grieken (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sander van Grieken updated CLK-744:
-----------------------------------

    Description: 
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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)

I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case


  was:
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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)

I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 ...



> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Closed: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bob Schellink closed CLK-744.
-----------------------------

    Resolution: Invalid

All Field#setValue works with Strings, not Options. It is consistent throughout the framework. It is also used for copying values to and from domain objects.

Passing in Option from DataProvider is a good thing as it communicates clearly what goes into the optionList to ther devs.

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Finn Bock (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12975912#action_12975912 ] 

Finn Bock commented on CLK-744:
-------------------------------

Just an observation, but if the Iterable returned from the DataProvider is *not* a List (perhaps a LinkedHashSet), then all the strings in the Iterable is automatically wrapped by an Option by the call to Select.add(). 

And I'm still in favor of a common interface on Option and OptionGroup.

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Sander van Grieken (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979280#action_12979280 ] 

Sander van Grieken commented on CLK-744:
----------------------------------------

Bob, may I propose to reopen this bug, perhaps changing priority to Wish or something?

Like Finn Bock said, if the underlying representation of the Iterable is not a List, the behaviour changes. So we got 3 paths of adding items, of which the List Iterable is the strange one :

- add (String/Option/OptionGroup)
- DataProvider non List Iterable (String/Option/OptionGroup)
- DataProvider List Iterable (Option/OptionGroup)

So it is not consistent.

I think allowing also Strings in the List case is a benefit, since it makes the ways of adding options consistent, and a convenience, since many DataProvider examples in the javadoc directly return the results from the backend call as Strings. It also conforms to the expected behaviour, as a click newbie like myself :)


> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979311#action_12979311 ] 

Bob Schellink commented on CLK-744:
-----------------------------------

Actually I've fixed Iterable to behave like a List, meaning Option and OptionGroup.

Strings might be beneficial to the developer but not to the maintainer. How will the label be rendered? It will depend on how Select interprets it. Using an Option there is one thing less for the maintainer to worry about. This leads to a Stronger codebase which is a good thing.

The add methods predates DP and not much we can do about it unless we deprecate them at some stage.

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Bob Schellink (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980035#action_12980035 ] 

Bob Schellink commented on CLK-744:
-----------------------------------

Another thing to keep in mind is with Options, we can just use the DP list as is. If we accpt Strings we have to iterate it to convert to Options. I don't want my apps to pay this price if I am doing the right thing and defining Options.

I think we should monitor the user list and if people complain we can revisit this issue.

> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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


[jira] Commented: (CLK-744) Select control's setValue is not usable due to insufficient wrapping

Posted by "Sander van Grieken (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLK-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12975772#action_12975772 ] 

Sander van Grieken commented on CLK-744:
----------------------------------------

I should have mentioned that this occurs when using a DataProvider..


> Select control's setValue is not usable due to insufficient wrapping
> --------------------------------------------------------------------
>
>                 Key: CLK-744
>                 URL: https://issues.apache.org/jira/browse/CLK-744
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0-M1, 2.2.0
>            Reporter: Sander van Grieken
>         Attachments: SelectTestPage.java
>
>
> 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. 'org.apache.click.control.Option@1c154a3') 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 org.apache.click.control.Select.render(Select.java:998)
> I have modified the render(HtmlStringBuffer buffer) method in Select.java 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 case

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