Announcement

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

    DataSource.get() problem

    Hello!

    SmartGWT EE 3.0, Chrome 21.0 and IE 9.

    I am trying to test the upload of a file to a database, but I am stuck in a NullPointerException, when trying to get the datasource from a ds.xml file.

    fileUpload.ds.xml
    Code:
    <DataSource ID="fileUpload" serverType="sql" tableName="GWTTESTS">  
        <fields>  
            <field name="FILE_VERSION" type="text"/>  
            <field name="FILE_BLOB" type="binary"/>  
        </fields>  
    </DataSource>
    GWTTests.html
    Code:
    <!doctype html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title></title>
    <script>
    var isomorphicDir = "gwttests/sc/";
    </script>
    <script type="text/javascript" language="javascript"
    	src="gwttests/gwttests.nocache.js"></script>
    </head>
    <body>
    <script SRC="sc/DataSourceLoader?dataSource=fileUpload"</script> 
    </body>
    </html>
    GWTTests.java
    Code:
    package local.tests.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.FileItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.layout.HLayout;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class GWTTests implements EntryPoint {
    
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
    
        	DataSource dataSource = DataSource.get("fileUpload");  
    
            final DynamicForm uploadForm = new DynamicForm();  
            uploadForm.setDataSource(dataSource);  
            uploadForm.setWidth(300);  
              
            TextItem versionItem = new TextItem("FILE_VERSION");  
      
            FileItem fileItem = new FileItem("FILE_BLOB");  
              
            ButtonItem saveItem = new ButtonItem("save", "SAVE");  
            saveItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {  
                public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {  
                    uploadForm.saveData(new com.smartgwt.client.data.DSCallback() {  
                        public void execute(DSResponse response, Object data, DSRequest request) {  
                            uploadForm.editNewRecord();  
                        }  
                    });  
                }  
            });  
      
            uploadForm.setFields(versionItem, fileItem, saveItem);
            
            HLayout topLayout = new HLayout();  
            topLayout.setMembers(uploadForm);  
              
            topLayout.draw(); 
    
        }
    }
    The datasource is parsed successfuly, as can be seen in console.txt. But it's returning nullPointerException when trying to set to the form (dev-console.txt).
    Attached Files

    #2
    See the FAQ for comprehensive troubleshooting instructions for any issue loading DataSources.

    Comment


      #3
      I've already check the list under "(SGWT Pro or better) I can't load my DataSource, DataSource.get() returns null", and as far as I see, I've got all the things in the right place.
      Is there any thing else that I should check?
      The xml is parsed, but when I call the uploadForm.setDataSource(dataSource), the dataSource is null.

      Comment


        #4
        You have a typo in your <script> tag:

        Code:
        <script SRC="sc/DataSourceLoader?dataSource=fileUpload"</script>
        No closing ">".

        Comment

        Working...
        X