ClassCastException in DefaultConverter.convertToString
------------------------------------------------------

                 Key: WICKET-2041
                 URL: https://issues.apache.org/jira/browse/WICKET-2041
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4-M3
            Reporter: Christian Spieß


Problem : 
Display of a DefaultMutableTreeNode without userObject (userObject=null)
will result in a class cast exception.

java.lang.ClassCastException: javax.swing.tree.DefaultMutableTreeNode cannot be 
cast to java.lang.String
     at 
org.apache.wicket.util.convert.ConverterLocator$DefaultConverter.convertToString(ConverterLocator.java:127)
     at 
org.apache.wicket.Component.getDefaultModelObjectAsString(Component.java:1653)
     at 
org.apache.wicket.Component.getDefaultModelObjectAsString(Component.java:1625)
     at 
org.apache.wicket.markup.html.basic.Label.onComponentTagBody(Label.java:115)
     at org.apache.wicket.Component.renderComponent(Component.java:2561)
     at 
org.apache.wicket.markup.html.WebComponent.onRender(WebComponent.java:62)
     at org.apache.wicket.Component.render(Component.java:2398)

Problem:

org.apache.wicket.util.lang.Objects
        public static Object convertValue(final Object value, final Class<?> 
toType)
        {
          //...
          return (result != null) ? result : value;
        }
        
result = null // because DefaultMutableTreeNode::toString() = null
so this function will return the DefaultMutableTreeNode object 
        
org.apache.wicket.util.convert.ConverterLocator :: DefaultConverter
                public String convertToString(X value, Locale locale)
                {
                        //...
                        return (String)Objects.convertValue(value, 
String.class);
                }

Here the DefaultMutableTreeNode will be cast to "(String)" which leads to a 
ClassCastException.

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

Reply via email to