Announcement

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

    RestDataSource XML not well-formed : Element type "isc_Class" containt $

    Using RestDataSource, and recent upgrade from SVN, now i'have errors with syntax of XML :

    RestDataSource XML : document is not well-formed : Firebug alert, and SAX Exception

    Firebug :
    Code:
    XML
    Erreur d'analyse XML : mal formé Emplacement : moz-nullprincipal:{a26ffc1e-5705-40eb-beb9-0a7670b7044b} Numéro de ligne 4, Colonne 19 :
    
            <isc_Class$RestDataSource_1>
    ------------------^
    
    Source
    <request> <data> <isc_Class$RestDataSource_1> <myfield>7AS</myfield> </isc_Class$RestDataSource_1> </data> <dataSource>isc_Class$RestDataSource_1</dataSource> <operationType>add</operationType> <oldValues></oldValues> </request>
    Server siden when reading/parsing XML :

    Code:
    org.xml.sax.SAXParseException: Element type "isc_Class" must be followed by either attribute specifications, ">" or "/>".
    On your showcase, i obtain same result :


    Code:
    POST http://www.smartclient.com/smartgwt/showcase/data/dataIntegration/xml/responses/country_add_rest.xml
    200 OK		362ms
    
    In POST :
    
    XML
    Erreur d'analyse XML : mal formé Emplacement : moz-nullprincipal:{625bac02-16b7-4f45-92f3-07af4b61cb92} Numéro de ligne 4, Colonne 37 :
    
            <isc_RestfulDataSourceSample$1_1>
    ------------------------------------^
    
    Source
    <request> <data> <isc_RestfulDataSourceSample$1_1> <countryCode>A1</countryCode> <countryName>New Value</countryName> <capital>New Value</capital> <continent>New Value</continent> </isc_RestfulDataSourceSample$1_1> </data> <dataSource>isc_RestfulDataSourceSample$1_1</dataSource> <operationType>add</operationType> <componentId>isc_ListGrid_1</componentId> <oldValues></oldValues> </request>
    Why have you add $ character ?
    Previously it was like :

    Code:
    	<request>
    	    <data>
    	        <isc_OID_1>
    	            <myfield>ALI</myfield>
    	        </isc_OID_1>
    	    </data>
    	    <dataSource>isc_OID_1</dataSource>
    	    <operationType>remove</operationType>
    	    <operationId></operationId>
    	    <startRow></startRow>
    	    <endRow></endRow>
    	    <sortBy></sortBy>
    	    <textMatchStyle></textMatchStyle>
    	    <oldValues></oldValues>
    	</request>
    How to remove $ char, for a well formed XML ? Something to set ?

    #2
    In DataSource.java

    Code:
        /**
         * Tag name to use when serializing to XML.  If unspecified, the <code>dataSource.ID</code> will be used.
         * <p><b>Note : </b> This is an advanced setting</p>
         *
         * @param tagName tagName Default value is null
         * @throws IllegalStateException this property cannot be changed after the underlying component has been created
         * @see com.smartgwt.client.docs.ClientDataIntegration ClientDataIntegration overview and related methods
         */
        public void setTagName(String tagName)  throws IllegalStateException {
            setAttribute("tagName", tagName, false);
        }
    And in BaseClass.java

    Code:
        public BaseClass() {
            id = SC.generateID(getClass().getName());
            setAttribute("ID", id, false);
        }
    
    
        protected BaseClass(JavaScriptObject jsObj) {
            String nativeID = JSOHelper.getAttribute(jsObj, "ID");
            this.id = nativeID;
        }
    In SC.java

    Code:
        public static native String generateID() /*-{        
            return $wnd.isc.ClassFactory.getNextGlobalID();
        }-*/;
    
        public static native String generateID(String className) /*-{
            var simpleName = className.substring(className.lastIndexOf(".")+1);
            return $wnd.isc.ClassFactory.getNextGlobalIDForClass(simpleName);
        }-*/;
    So i understand why "RestDataSource_1" with new RestDataSource,
    but not why "<isc_Class$RestDataSource_1>" ?
    ...

    One solution is to set the advanced setting :
    Code:
    restDataSource.setTagName("tagName");
    and you obtain "<tagName>" instead of "<isc_Class$RestDataSource_1>"

    But, how to obtain correct tag name without use advanced setting (as before) ?...
    Last edited by immobilia; 1 Dec 2010, 08:55.

    Comment


      #3
      No one else has reported this yet.. please try putting together a standalone test case that demonstrates an issue, so that it's clear that the bad tagName is coming from the framework and not somehow indirectly coming from your code.

      Comment


        #4
        Juste enable Firebug, to see XML syntax error, on showcase for exemple (when fetching datas)

        I copy/past on local computer and same result :

        Tabs of firebug :
        * Paramètres
        * En-têtes
        * Post
        * Réponse
        * XML

        When fetching data, client side send (Post) to server XML content :

        <request>
        <data>
        <isc_SmartGwtXmlDataSource>
        <dataSource>isc_SmartGwtXmlDataSource$1_0</dataSource>
        <operationType>fetch</operationType>
        <startRow>0</startRow>
        <endRow>50</endRow>
        <sortBy>countryCode</sortBy>
        <textMatchStyle>substring</textMatchStyle>
        <componentId>isc_ListGrid_0</componentId>
        <oldValues></oldValues>
        </isc_SmartGwtXmlDataSource>
        </data>
        </request>

        And $ is invalid for XML, like firebug alert on "$" character :

        XML analyse error : not well formed Emplacement : moz-nullprincipal:{fc12cb52-8343-4c8c-871a-a66be153c894} Numéro de ligne 4, Colonne 35 :

        <isc_SmartGwtXmlDataSource$1_0/>
        -----------------------------------^

        Using
        * GWT 2.0.4
        * SmartGwt build r1514 (smartgwt.jar)

        Code:
        package com.placeoweb.client;
        
        import com.google.gwt.core.client.EntryPoint;
        import com.google.gwt.user.client.Window;
        import com.smartgwt.client.data.DSRequest;
        import com.smartgwt.client.data.DSResponse;
        import com.smartgwt.client.data.OperationBinding;
        import com.smartgwt.client.data.RestDataSource;
        import com.smartgwt.client.data.fields.DataSourceTextField;
        import com.smartgwt.client.types.ContentsType;
        import com.smartgwt.client.types.DSOperationType;
        import com.smartgwt.client.types.DSProtocol;
        import com.smartgwt.client.widgets.HTMLPane;
        import com.smartgwt.client.widgets.IButton;
        import com.smartgwt.client.widgets.events.ClickEvent;
        import com.smartgwt.client.widgets.events.ClickHandler;
        import com.smartgwt.client.widgets.grid.ListGrid;
        import com.smartgwt.client.widgets.grid.ListGridField;
        import com.smartgwt.client.widgets.layout.HLayout;
        import com.smartgwt.client.widgets.layout.VLayout;
        import com.smartgwt.client.widgets.tab.Tab;
        import com.smartgwt.client.widgets.tab.TabSet;
        
        public class SmartGwtXmlDataSource implements EntryPoint {
        
        	@Override
        	public void onModuleLoad() {
        
        		VLayout layout = new VLayout(15);  
        		layout.setAutoHeight();  
        
        		//overrides here are for illustration purposes only   
        		RestDataSource countryDS = new RestDataSource() {  
        			@Override  
        			protected Object transformRequest(DSRequest dsRequest) {  
        				return super.transformRequest(dsRequest);  
        			}  
        			@Override  
        			protected void transformResponse(DSResponse response, DSRequest request, Object data) {  
        				super.transformResponse(response, request, data);  
        			}  
        		};  
        
        		DataSourceTextField countryCode = new DataSourceTextField("countryCode", "Code");  
        		OperationBinding fetch = new OperationBinding();  
        		fetch.setOperationType(DSOperationType.FETCH);  
        		fetch.setDataProtocol(DSProtocol.POSTMESSAGE);  
        		OperationBinding add = new OperationBinding();  
        		add.setOperationType(DSOperationType.ADD);  
        		add.setDataProtocol(DSProtocol.POSTMESSAGE);  
        		OperationBinding update = new OperationBinding();  
        		update.setOperationType(DSOperationType.UPDATE);  
        		update.setDataProtocol(DSProtocol.POSTMESSAGE);  
        		OperationBinding remove = new OperationBinding();  
        		remove.setOperationType(DSOperationType.REMOVE);  
        		remove.setDataProtocol(DSProtocol.POSTMESSAGE);  
        		countryDS.setOperationBindings(fetch, add, update, remove);  
        
        
        		countryCode.setPrimaryKey(true);  
        		countryCode.setCanEdit(false);  
        
        		DataSourceTextField countryName = new DataSourceTextField("countryName", "Country");  
        		DataSourceTextField capital = new DataSourceTextField("capital", "Capital");  
        		countryDS.setFields(countryCode, countryName, capital);  
        		countryDS.setFetchDataURL("data/dataIntegration/xml/responses/country_fetch_rest.xml");  
        		countryDS.setAddDataURL("data/dataIntegration/xml/responses/country_add_rest.xml");  
        		countryDS.setUpdateDataURL("data/dataIntegration/xml/responses/country_update_rest.xml");  
        		countryDS.setRemoveDataURL("data/dataIntegration/xml/responses/country_remove_rest.xml");  
        
        		final ListGrid countryGrid = new ListGrid();  
        		countryGrid.setWidth(500);  
        		countryGrid.setHeight(224);  
        		countryGrid.setDataSource(countryDS);  
        		countryGrid.setEmptyCellValue("--");  
        
        
        		ListGridField codeField = new ListGridField("countryCode");  
        		ListGridField nameField = new ListGridField("countryName");  
        		ListGridField capitalField = new ListGridField("capital");  
        		ListGridField continentField = new ListGridField("continent", "Continent");  
        		countryGrid.setFields(codeField, nameField, capitalField, continentField);  
        		countryGrid.setSortField(0);  
        		countryGrid.setDataPageSize(50);  
        		countryGrid.setAutoFetchData(true);  
        
        		layout.addMember(countryGrid);  
        
        		HLayout hLayout = new HLayout(15);  
        
        		final IButton addButton = new IButton("Add new Country");  
        		addButton.setWidth(150);  
        		addButton.addClickHandler(new ClickHandler() {  
        			public void onClick(ClickEvent event) {  
        				countryGrid.addData(new CountryRecord("A1", "New Value", "New Value", "New Value"));  
        				addButton.disable();  
        			}  
        		});
        		hLayout.addMember(addButton);  
        
        		layout.addMember(hLayout);  
        
        		layout.draw();  		
        
        	}
        
        }

        Comment


          #5
          The fix will be in the next nightly build.

          Comment


            #6
            Ok, thanks,
            build.1515 02-Dec-2010 04:12 include changes, but doesnt work for me :

            com.google.gwt.core.client.JavaScriptException: (TypeError): simpleName.replaceAll is not a function


            I think, you mistake using "replaceAll" instead "replace" (native javascript)

            Code:
            public class SmartGwtAlert implements EntryPoint {
            
            	@Override
            	public void onModuleLoad() {
            		
            //		r1514
            //	    public static native String generateID(String className) /*-{
            //        var simpleName = className.substring(className.lastIndexOf(".")+1);
            //        return $wnd.isc.ClassFactory.getNextGlobalIDForClass(simpleName);
            //    }-*/;		
            //		
            //		r1515
            //	    public static native String generateID(String className) /*-{
            //        var simpleName = className.substring(className.lastIndexOf(".")+1);
            //        //replace any $ characters from inner class names with an underscore
            //        simpleName = simpleName.replaceAll("$", "_");
            //        return $wnd.isc.ClassFactory.getNextGlobalIDForClass(simpleName);
            //    }-*/;		
            		
            		
            //		String string = "MyClass$IsBad";
            		String string = this.getClass().toString();
            				
            		SC.say("One bad ID : " + string);
            //		One bad ID : class com.placeoweb.client.SmartGwtAlert		
            		
            		string = SC.generateID(string);
            //		com.google.gwt.core.client.JavaScriptException: (TypeError): simpleName.replaceAll is not a function
            		
            		SC.say("is Convert to ID : " + string);
            		
            	}
            
            }
            Last edited by immobilia; 2 Dec 2010, 07:32.

            Comment

            Working...
            X