You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Richard Emberson (JIRA)" <ji...@apache.org> on 2011/02/09 19:05:57 UTC

[jira] Created: (WICKET-3439) org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml

org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml
------------------------------------------------------------------------------------------

                 Key: WICKET-3439
                 URL: https://issues.apache.org/jira/browse/WICKET-3439
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5-RC1
         Environment: all
            Reporter: Richard Emberson
            Priority: Minor


In class org.apache.wicket.markup.html.form.AbstractChoice<T, E> the renderer instance 
variable has signature:
  private IChoiceRenderer<? super E> renderer;
In the method appendOptionHtml the renderer's getDisplayValue method is called as follows:
  T objectValue = (T)renderer.getDisplayValue(choice); 
where the signature for the IChoiceRenderer<E> getDisplayValue method is:
  Object getDisplayValue(E object);

So, is it a fact that for all usages of AbstractChoice that the display value returned by a
renderer of type E will always be of type T (not Object)??? If not, then one should expect cast 
exceptions.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (WICKET-3439) org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml

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

Igor Vaynberg resolved WICKET-3439.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.5-RC2
         Assignee: Igor Vaynberg

CheckBoxMultipleChoice had the most correct implementation.

the renderer can really return Object of class that is not tied to any type parameters of the choice component. it is wicket's job then to take this Object and convert it into its String representation using a converter. the getConverter() method is also not tied to the parameter type of the choice component, and so should not be iconverter<t> but rather raw converter since we do not know at compile time which one it will actually be.

> org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml
> ------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3439
>                 URL: https://issues.apache.org/jira/browse/WICKET-3439
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5-RC1
>         Environment: all
>            Reporter: Richard Emberson
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.5-RC2
>
>
> In class org.apache.wicket.markup.html.form.AbstractChoice<T, E> the renderer instance 
> variable has signature:
>   private IChoiceRenderer<? super E> renderer;
> In the method appendOptionHtml the renderer's getDisplayValue method is called as follows:
>   T objectValue = (T)renderer.getDisplayValue(choice); 
> where the signature for the IChoiceRenderer<E> getDisplayValue method is:
>   Object getDisplayValue(E object);
> So, is it a fact that for all usages of AbstractChoice that the display value returned by a
> renderer of type E will always be of type T (not Object)??? If not, then one should expect cast 
> exceptions.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-3439) org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml

Posted by "Richard Emberson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992637#comment-12992637 ] 

Richard Emberson commented on WICKET-3439:
------------------------------------------

As a follow up to the previous comment, the CheckBoxMultipleChoice appendOptionHtml method is:
    Object displayValue = getChoiceRenderer().getDisplayValue(choice);        
    Class<?> objectClass = displayValue == null ? null : displayValue.getClass();
    // Get label for choice
    String label = "";
    if (objectClass != null && objectClass != String.class)                   
    {     
      IConverter converter = getConverter(objectClass);                       
      label = converter.convertToString(displayValue, getLocale());           
    }     
    else if (displayValue != null)                                            
    {     
      label = displayValue.toString();                                        
    }     
....

But the IConverter should really be:
      IConverter<T> converter = getConverter(objectClass);     
and, therefore, the displayValue really has to be of type T.                  


> org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml
> ------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3439
>                 URL: https://issues.apache.org/jira/browse/WICKET-3439
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5-RC1
>         Environment: all
>            Reporter: Richard Emberson
>            Priority: Minor
>
> In class org.apache.wicket.markup.html.form.AbstractChoice<T, E> the renderer instance 
> variable has signature:
>   private IChoiceRenderer<? super E> renderer;
> In the method appendOptionHtml the renderer's getDisplayValue method is called as follows:
>   T objectValue = (T)renderer.getDisplayValue(choice); 
> where the signature for the IChoiceRenderer<E> getDisplayValue method is:
>   Object getDisplayValue(E object);
> So, is it a fact that for all usages of AbstractChoice that the display value returned by a
> renderer of type E will always be of type T (not Object)??? If not, then one should expect cast 
> exceptions.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-3439) org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml

Posted by "Richard Emberson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992630#comment-12992630 ] 

Richard Emberson commented on WICKET-3439:
------------------------------------------

Also, in CheckBoxMultipleChoice appendOptionHtml method there is:
  Object displayValue = getChoiceRenderer().getDisplayValue(choice);
Should this also be:
  T displayValue = (T)getChoiceRenderer().getDisplayValue(choice); 

> org.apache.wicket.markup.html.form.AbstractChoice renderer cast in method appendOptionHtml
> ------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3439
>                 URL: https://issues.apache.org/jira/browse/WICKET-3439
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5-RC1
>         Environment: all
>            Reporter: Richard Emberson
>            Priority: Minor
>
> In class org.apache.wicket.markup.html.form.AbstractChoice<T, E> the renderer instance 
> variable has signature:
>   private IChoiceRenderer<? super E> renderer;
> In the method appendOptionHtml the renderer's getDisplayValue method is called as follows:
>   T objectValue = (T)renderer.getDisplayValue(choice); 
> where the signature for the IChoiceRenderer<E> getDisplayValue method is:
>   Object getDisplayValue(E object);
> So, is it a fact that for all usages of AbstractChoice that the display value returned by a
> renderer of type E will always be of type T (not Object)??? If not, then one should expect cast 
> exceptions.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira