Announcement

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

    Dynamic Data Source on server-side

    Hi,

    we want to use a list-grid for showing large amounts of data, but we don't know the columns and data-types of the list grid before sending the request to the server. On server-side a function returns the column-names and data in a table-result-set. Due to the large amount of data we need paging and therefore a server-side data source. Therefore we want to call the function via DMI and create the data source on server-side "on-thy-fly".

    I looked through the whole forum and found this thread in respect of dynamic data sources: http://forums.smartclient.com/showthread.php?t=8573


    Rearding the usage of dynamic data sources I have now a couple of questions:

    1.) Do you have a full example how to use "DataSource.fromXML()" dynamically on server-side with all needed source code (I think it is extremely helpful to have such a full example instead of trying it with the hints of the above mentioned thread)?

    2.) Is it really necessary to subclass the IDA Call built-in servlet + creating a JSP/Servlet which does the same as the DataSourceLoader servlet or is there an easier way to create server-side data sources dynamically?

    3.) If one creates the DataSource on server-side via "DataSource.fromXML()", is it anyhow necessary to create a static XML data source descriptor (which contents will be replaced at run-time via "DataSource.fromXML()")?

    We are currently evaluating "Smart GWT" and thinking of buying the enterprise edition, but the handling of these dynamic aspects will be the relevant criteria (all other features are great!!!). Therefore it would be very helpful to see working examples as described in point 1.). "Possible" solutions from forums with only smart portions of code would not be sufficient.

    Looking forward for an answer.

    Florian

    #2
    There is a recently added server-side API that makes this simpler - DataSource.addDynamicDSGenerator(). By adding a DataSource generator that simply calls fromXML() to create it's DataSource, you no longer have to subclass IDACall or create a special way of delivering the DataSource to the browser (the DataSourceLoader servlet will work normally).

    Comment


      #3
      Thanks for the fast reply - that sounds good. In which namespace is it? I would expect it in 'com.isomorphic.datasource.DataSource', but I can't find it (Enterprise evaluation version, we donloaded last week).

      Could you anyhow provide an example how to use it? A short explanation of the steps would be helpful.

      And coming back to the 3rd question: Is it anyhow necessary to create a static XML data source descriptor (which contents will be replaced at run-time via "DataSource.fromXML()")?

      Thanks

      Florian

      Comment


        #4
        It's recent - get a nightly to try it out (smartclient.com/builds) and look at the JavaDoc

        No, you do not need a static DataSource descriptor.

        Comment


          #5
          O.k. - I will check it in the evaluation version. When will it officially released?

          Comment


            #6
            Sorry, I can't find it.

            I browsed to http://www.smartclient.com/builds and downloaded just a few minutes ago the nightl build "SmartGWT/2.x/Eval/2010-11-25". I imported the sample-project "custom-ds". Here I tried to call the method "DataSource.addDynamicDSGenerator()", but it is not availabe. Also in the Java-Docs I can't find any description about this method.

            So where can I find it?

            And again the question: When will this functionality officially released?

            Comment


              #7
              Sorry, there was an issue with the JavaDocs, now corrected (get the next nightly).

              It will be released with 2.4, currently slated for early December.

              Comment


                #8
                Originally posted by Isomorphic
                There is a recently added server-side API that makes this simpler - DataSource.addDynamicDSGenerator(). By adding a DataSource generator that simply calls fromXML() to create it's DataSource, you no longer have to subclass IDACall or create a special way of delivering the DataSource to the browser (the DataSourceLoader servlet will work normally).
                In this case, how can I get the dynamic data source from client side? I think I cannot use ds = DataSource.get(dsId) to get the datasource, because it is created yet.

                Comment


                  #9
                  I was recently experimenting with all of this. Once you're certain your DynamicDSGenerator has been added, you need to "load" the DataSource at least once on the client side, like this:

                  Code:
                  try{
                    DataSource.load("dstest",new Function() 
                    {
                      public void execute()
                      {
                        Log.warn("Got here after load, seeking dstest...");
                  
                        DataSource ds = DataSource.get("dstest");
                  
                        if (ds == null){
                          Log.warn("Couldn't find DataSource 'dstest'??");
                        }
                        else{
                          Log.warn("Got dstest...");
                  	DataSourceField[] fields = ds.getFields();
                          for (DataSourceField field : fields){
                             Log.warn("field: " + field.getName() + ", " + field.getType());
                          }
                        }
                      }
                    }, false);
                  }
                  catch (Throwable t){
                    Log.error("Error loading/getting dstest?",t);
                  }

                  Comment


                    #10
                    Can not get Dynamic DataSource load working

                    I am trying to switch database instances in a mysql database server. I tried adding a dynamic datasource generator and added the database instances to server.properties. Can anyone help me with and example of one Database Server and accessing different database instances? I've been searching and example and been searching the web for the last two days. Any help would be greatly appreciated.

                    -- Jeff

                    Comment


                      #11
                      A user posted a complete example of this here.

                      Comment

                      Working...
                      X