Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    java.lang.ClassCastException

    I get this error when a multi-value datasource field is empty/null/missing.

    Code:
    java.lang.ClassCastException: java.lang.String cannot be cast to com.google.gwt.core.client.JavaScriptObject
        at com.smartgwt.client.util.JSOHelper.getAttributeAsJavaScriptObject(JSOHelper.java)
        at com.smartgwt.client.util.JSOHelper.getAttributeAsStringArray(JSOHelper.java:310)
        at com.smartgwt.client.core.DataClass.getAttributeAsStringArray(DataClass.java:115)
        at com.logalyze.admin.web.client.data.LogDefinitionDataSource.transformResponse(LogDefinitionDataSource.java:83)
    LogDefinitionDataSource.java:83:
    Code:
    String value[] = record.getAttributeAsStringArray("tag");
    If 'tags' exist (this is an xml datasource (SOAP)) they look like this:
    <record>
    <tag>a</tag>
    <tag>b</tag>
    </record>


    SmartGWT 2.4 GPL.

    #2
    The only way I can handle this:

    Code:
    String stringvalue = grid.getSelectedRecord().getAttributeAsString("tag");
    if(stringvalue!=null){
    	if(stringvalue.indexOf(',')>-1){
    		// There are more tags
    		String[] tags = grid.getSelectedRecord().getAttributeAsStringArray("tag");
    		if(tags!=null){
    			//System.out.println("Tags array size:"+tags.length);
    			for(String tag : tags){
    				... doing something with tag ...
    			}
    		}
    	}else{
    		// There is only 1 tag
    		... doing something with tag ...
    	}
    	stringvalue = null;
    }

    Any idea?

    Comment

    Working...
    X