Announcement

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

    DataSource inheritance

    Is there a way to have datasource xml file extend another datasource xml, similar to classes.
    can this be acomplished by using foreign key in the datasource?
    Thanks

    #2
    See DataSource.setInheritsFrom().

    Comment


      #3
      Here is a sample code:

      DataSource DS1 = DataSource.get("DS1");
      DataSource DS2 = DataSource.get("DS2");
      DS2.setInheritsFrom(DS1);

      I'm getting the folowing exception, what is wrong? What is the proper way for DS2 to inherit from DS1???

      java.lang.IllegalStateException: Cannot change configuration property 'inheritsFrom' to [DataSource ID:rDS1] after the component has been created.

      Comment


        #4
        Where is the DataSource "DS1" created? Try setting setInheritsFrom at the point where you are creating it.

        Sanjiv

        Comment


          #5
          I tried the following, but still getting same exception. Any idea why it's happening? Can you please supply some sample code where you know it works?
          I looked at the examples, but there is nothing there. Thanks in advance.


          DS2.setInheritsFrom(DataSource.get("DS1"));

          Comment


            #6
            Please post your code where you're creating the datasources.

            Comment


              #7
              Here it is, but it's not working, same exception thrown.

              DataSource DS2 = DataSource.get("DS2");
              DS2.setInheritsFrom(DataSource.get("DS1"));

              Comment


                #8
                How is the datasource "DS1" created? Are you using SmartGWT LGPL, or SmartGWT EE?

                Comment


                  #9
                  I'm using SmartGWT EE
                  I'm loading datasources in the html page the following way:

                  <script src="sc/DataSourceLoader?dataSource=DS1"></script>
                  <script src="sc/DataSourceLoader?dataSource=DS2"></script>

                  Data Sources are loaded correctly and without inheritance they working correctly, but I need to use inheritance since DS2 has to include fields from DS1

                  Comment


                    #10
                    Try adding "inheritsFrom" attribute in the DataSource tag of the XML datasource definition of DS2 itself with a value of "DS1".

                    Comment


                      #11
                      it worked. Thanks a lot

                      Comment


                        #12
                        Hi Guys ...
                        Thanks for your help so far ... again I'm trying to run one of your server examples but against a MySql db and running on jboss. I have it successfully up and running for a custom xml datasource (cool). I've added in inherits from and the list grid has stopped working and I don't know why :(

                        Heres my Datasource ... like I said without the inheritsfrom it works, am I using it correctly ? Do you have a link to the DTD/Grammer somewhere, I can't seem to find it.

                        Code:
                        <DataSource ID="CustomerFacingService"
                        	    inheritsFrom="ServiceType">
                        	<fields>
                        		<field name="containedByCFS" title="Contained By CFS" type="text" foreignKey="CustomerFacingService.name" required="false" detail="false" canEdit="true"/>
                        		<field name="containsCFSList" title="Contains CFS List" type="text" foreignKey="CustomerFacingService.name" required="false" detail="true" canEdit="true" multiple="true"/>
                        		<field name="rfsList" title="Resource Facing Services" type="text" foreignKey="ResourceFacingService.name" required="false" detail="true" canEdit="true" multiple="true"/>
                        		<field name="product" title="Product Name" type="text" foreignKey="Product.name" required="false" detail="false" canEdit="true" multiple="false"/>
                        	</fields>
                        </DataSource>
                        Code:
                        <DataSource ID="ServiceType">
                            <fields>
                                <field name="hasStarted" title="Has Started" type="boolean"/>
                            </fields>
                        </DataSource>

                        Comment


                          #13
                          I had one other quick one as well ...
                          Is there a coding alternative to the DataSourceLoader call in the html file launching the client application i.e. this line
                          Code:
                            <script src="sc/DataSourceLoader?dataSource=blah"</script>
                          Can I do it within my client application ... say driven from a server file and have it completely dynamic ?

                          Comment


                            #14
                            Hi Mike,

                            The DataSourceLoader produces a JavaScript response. You could use the RPCManager with an RPCRequest where evalResult is enabled to load a DataSource at any time.

                            As far as your issue with inheritsFrom:

                            1. ensure both DataSource are loaded, with the inheriting DataSource second

                            2. ensure both DataSources have an ID that agrees with the filename where they are saved (should be dataSourceID.ds.xml, and is case sensitive)

                            3. look in both the client-side logs (in the Developer Console) and server-side logs for any possible error messages or warnings

                            Comment


                              #15
                              ClassCastException

                              That worked ... thanks ...

                              I have added the sql tags (serverType, tableName, recordName) to the derived object but not to the base and the query works perfectly but when I do an add I get a class cast exception

                              Code:
                              java.lang.ClassCastException: com.isomorphic.datasource.BasicDataSource cannot be cast to com.isomorphic.sql.SQLDataSource
                              	at com.isomorphic.sql.SQLDataSource.getSequences(SQLDataSource.java:249)
                              	at com.isomorphic.sql.SQLValuesClause.getSQLStringForInsert(SQLValuesClause.java:142)
                              	at com.isomorphic.sql.SQLDataSource.getClausesContext(SQLDataSource.java:1393)
                              	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:973)
                              	at com.isomorphic.sql.SQLDataSource.execute(SQLDataSource.java:193)
                              	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:708)
                              	at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:665)
                              	at com.isomorphic.application.AppBase.execute(AppBase.java:498)
                              Do I need to tag the base xml file as well ? We were hoping to have inheritance in our XML objects but to have a single db table per object.

                              Comment

                              Working...
                              X