Announcement

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

    #16
    OK, the release notes say that in 0.9p you "Fixed a ClassCastException in DataSource.fromConfig()".

    Now take into account these facts:

    1. I have never used any version prior to 1.0

    2. paibanez (the original poster) has reported a problem but in his stack it was at DataSource.fromConfig(DataSource.java:1580), my stack is at DataSource.fromConfig(DataSource.java:1643)

    3. I just downloaded 1.0 once more and unzippped on another computer so you cannot say that it's due to my environment. I unzipped the jar file and the source is exactly the one I have debugged.

    The faulty line is:

    Code:
    	                OperationBinding binding = (OperationBinding)bindings.get(i);
    The full method code extracted from smartgwt-mobile.jar 1.0 is:

    Code:
        protected static DataSource fromConfig(String configText) {
            // Strip off extraneous SmartClient object creation stuff - we just want the config
            int start = configText.indexOf("{");
            int end = configText.lastIndexOf("}") + 1;
            if (start == -1 || end < start) return null;
            String forEval = configText.substring(start, end);
            Map<String, Object> config = JSONUtils.toRecord(JSONUtils.evalJSONString(forEval));
    
            DataSource ds = new DataSource((String)config.get("ID"));
            @SuppressWarnings("unchecked")
            List<Record> fields = (List<Record>)config.get("fields");
            DataSourceField[] dsFields = new DataSourceField[fields.size()];
            if (fields != null) {
                for (int i = 0; i < fields.size(); i++) {
                    dsFields[i] = new DataSourceField(fields.get(i));
                }
            }
            @SuppressWarnings("unchecked")
            List<OperationBinding> bindings = (List<OperationBinding>)config.get("operationBindings");
            OperationBinding[] operationBindings = null;
            if (bindings != null) {
            	operationBindings = new OperationBinding[bindings.size()];
    	        if (fields != null) {
    	            for (int i = 0; i < bindings.size(); i++) {
    	                OperationBinding binding = (OperationBinding)bindings.get(i);
    	                operationBindings[i] = new OperationBinding(binding);
    	            }
    	        }
            }
    
            for (Map.Entry<String, Object> e : config.entrySet()) {
                ds.attributes.put(e.getKey(), e.getValue());
            }
    
            ds.setFields(dsFields);
            if (operationBindings != null) ds.setOperationBindings(operationBindings);
    
            return ds;
        }

    Comment

    Working...
    X