Announcement

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

    #16
    Okay, i also have integrated client side using a jsp but the problem i have is - it doesn't seem to find out DMI fetch operation.

    And the error i get is "Operation fetch is not supported" even although operation binding is defined in the data source.

    Also. in my case Data source is not just generated once for a single run instance instead it has to be generated based on user logged in and few runtime parameters so how can we make sure that JSP call and custom IDACAll servlet will always return same information?

    Please suggest.
    Last edited by rathiandi; 25 Nov 2009, 13:31.

    Comment


      #17
      DMI did not work at all so i ended up adding serverConstructor and that did the job. It works now.

      But my biggest question still stand - In my case Data source is not just generated once for a single run instance instead it has to be generated based on user logged in and few runtime parameters so how can we make sure that JSP call and custom IDACAll servlet will always return same information?

      Can you please point us in right direction?

      Comment


        #18
        Further questions about doing this

        Originally posted by Isomorphic
        ...
        To generate a DataSource dynamically server-side, create the XML on the fly on the server and pass it to DataSource.fromXML(). You must do this in the server-side processing chain *before* the DataSource would need to be accessed for the first time, that is, you'll need to create your own servlet that creates the RPCManager class, calls getRequests(), and iterates through them.
        Does this really have to be done inside the server-side processing chain, each time there is a request?

        Can't this be done just once, outside the chain, when server server side is initializing? (I thought I generate the new DS XML, save it in the usual directory, and then let things go the usual way.)

        If your DataSource file remains at the same location and is in the same format, nothing changes about client-side behavior, but the client will only see the fields declared in the actual file.

        To make the client see the dynamic fields, create a .jsp or servlet that produces the same thing the DataSourceLoader servlet produces (JavaScript DataSource definitions) by again calling DataSource.fromXML() with dynamic XML and now also using JSTranslater.toJS() to transform the dynamic DataSource to JS (which the JSP or servlet should stream back as its HTTP response). Then just point a <script src=> tag at the URL of this servlet/.jsp
        Can I avoid having to duplicate the DataSource loading logic my saving the dynamically generated definition back to the shared/ds directory, and have the default loader load it?

        generate the XML DataSource definition dynamically and call DataSource.fromXML(). You can then take the DSRequest and pass it to DataSource.execute().

        In my version (SmargGWT-Pro, 2.0), the class com.isomorphic.datasource.DataSource no longer has an "execute" method.
        Where did it go?

        Comment


          #19
          Originally posted by jay.l.fisher
          I've made more progress and am sure that I'm executing my new code on the server side, but it seems that the IDACall.handleDSRequest method is only called when requesting the actual data from the data source, not the data source definition. Is IDACall the right servlet to be subclassing and if so, am I overriding the correct method?
          What was the answer to this question?

          Comment


            #20
            Yes, you can generate it just once and save it. Think carefully about clustering however (need to make sure all servers generate the same file).

            Regardless, you don't have to "duplicate" logic. Call the same logic from both places instead.

            There is no separate call to load the DataSource. See previous comments about having a jsp or servlet that returns the same thing that the built-in DataSourceLoader servlet returns - you just target just a .jsp or servlet with a <script src=> tag in your host .html file.

            DataSource.execute() is still there, with the same behavior, and is still the override point we suggest for many use cases. What makes you think it was removed?

            Comment


              #21
              Originally posted by Isomorphic
              Yes, you can generate it just once and save it.
              Which APIs should I use for this?

              Originally posted by Isomorphic
              DataSource.execute() is still there, with the same behavior, and is still the override point we suggest for many use cases. What makes you think it was removed?
              From my copy of SmartGWT-Pro,

              smartgwtpro-2.0/doc/server/javadoc/com/isomorphic/datasource/DataSource.html

              Comment


                #22
                Posts 7 and 9 in this thread contain actual code samples.

                Comment


                  #23
                  Originally posted by Isomorphic
                  Yes, you can generate it just once and save it.
                  OK, I am doing this, and this works OK. (The API I was looking for was
                  BuiltinRPC.saveSharedXML, but never mind.)

                  DataSource.execute() is still there, with the same behavior, and is still the override point we suggest for many use cases. What makes you think it was removed?
                  Now I see that it is indeed there, it's just missing from the related JavaDoc. (It's weird, though.)
                  Last edited by csillag; 20 Dec 2009, 06:21.

                  Comment


                    #24
                    You don't want to be using BuiltinRPC.saveSharedXML() - this is for Visual Builder only and not a documented API. Simply use normal Java IO to save to the filesystem.

                    Comment


                      #25
                      Originally posted by Isomorphic
                      You don't want to be using BuiltinRPC.saveSharedXML() - this is for Visual Builder only and not a documented API. Simply use normal Java IO to save to the filesystem.
                      How do I get the config option project.datasources (which is generally shared/ds), so that I can save things to the right place?

                      Comment


                        #26
                        For now, we'd recommend using a separate approach for configuring your code vs setting this property in server.properties and just ensuring the values stay in sync. We may later add some convenience methods to help discovering these settings at runtime.

                        Comment


                          #27
                          Hello,

                          I have a similar need in my project. I need to create the datasource on the
                          fly depending on the user's preference settings and also access privileges.
                          I was able to successfully populate the datasource with the additional
                          custom fields (definition only).

                          The problem I have is related to loading the data from the tables.

                          In my case, the extra fields do not correspond to table columns, but instead
                          they correspond to table rows (data). I have 2 tables - ProductMaster
                          and ProductDetails table.

                          <DataSource
                          dbName="Oracle"
                          tableName="PRODUCT_MASTER"
                          ID="PRODUCT_MASTER"
                          serverType="sql"
                          >

                          <fields>
                          <field primaryKey="true" name="PRD_ID" type="sequence"></field>
                          <field name="NAME" title="Name" length="50" type="text"></field>
                          <field name="CATEGORY" title="Category" length="50" type="text"></field>
                          <field name="PRICE" title="Price" length="10" type="number"></field>
                          </fields>

                          <serverObject lookupStyle="spring" bean="prdMasterDataDao"/>

                          </DataSource>


                          <DataSource
                          dbName="Oracle"
                          tableName="PRODUCT_DETAILS"
                          ID="PRODUCT_DETAILS"
                          serverType="sql"
                          >

                          <fields>
                          <field primaryKey="true" name="PRD_ATTR_ID" type="sequence"></field>
                          <field primaryKey="true" name="PRD_ID" type="sequence"></field>
                          <field name="PRD_ATTR_KEY" length="20" type="text"></field>
                          <field name="PRD_ATTR_VALUE" length="50" type="text"></field>
                          </fields>

                          <serverObject lookupStyle="spring" bean="prdDetailsDataDao"/>

                          </DataSource>

                          The reason behind this table structure is that each customer might have
                          unique catalog fields related to each product. I want to load the productGrid
                          as below (2 examples relating to 2 different customers):

                          ID Name Category Price Units Brand Manufacturer
                          1 N1 C1 $1.00 LB B1 M1
                          2 N2 C2 $0.50 KG B2 M2

                          ID Name Category Price Units Weight StorageCriteria
                          3 N3 C1 $5.00 Litres 1.0 -5F to 75F
                          4 N4 C3 $2.00 KG 1.0 Below 75F

                          I am now stuck at trying to creating/populating the grids as shown below.
                          Any pointers would be much appreciated.

                          Thanks & Regards.

                          Comment


                            #28
                            @chess You should start by reading the complete contents of this thread (it doesn't appear as though you have done this yet).

                            Comment


                              #29
                              Dear Isomorphic,

                              I did read the contents of this thread completely. I followed the same
                              approach as Jay did. The sample code that Jay posted (posts #7 and #9)
                              were very useful. The only modification I made was to create a DOM object
                              from the XML and added additional fields to it. It works fine.

                              I need help with the following:

                              "To make the client see the dynamic fields, create a .jsp or servlet that produces the same thing the DataSourceLoader servlet produces (JavaScript DataSource definitions) by again calling DataSource.fromXML() with dynamic XML and now also using JSTranslater.toJS() to transform the dynamic DataSource to JS (which the JSP or servlet should stream back as its HTTP response). Then just point a <script src=> tag at the URL of this servlet/.jsp"

                              Any sample code/example would be very helpful. I would really appreciate
                              if Jay or Isomorphic can share a small example illustrating this.

                              Comment


                                #30
                                In my case I created a class that reads the base ds.xml and adds fields to it with a method to return the modified xml as a string; ItemMasterDS().getDSString() in the example. Then in my servlet I used JSTranslater to convert the modified xml to javascript and send that back in the response.
                                Code:
                                DataSource ds = DataSource.fromXML(new ItemMasterDS().getDSString());
                                JSTranslater jst = new JSTranslater();
                                String js = jst.toJS(ds);
                                response.getWriter().write(js);

                                Comment

                                Working...
                                X