Announcement

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

    ResultTree returned wrong value for isFolder?

    Hi,

    I have been following the instruction on

    http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/tree/ResultTree.html

    I have a DataSource for such a result tree for which I have defined a field called "isFolder". The ds.xml looks like this

    Code:
        ...
        <fields>
            ...
            <field name="isFolder" type="boolean"    title="Is Folder" required="true"   />
        </fields> 
        <operationBindings>
            <operationBinding   operationType="fetch"  >
                <selectClause>
                    ...
                    , if(treeNodeType='FOLDER', true, false) as isFolder
                    ...
    I checked with my DB (MySQL) and confirmed that the select clause would return correct values (true or false, depending on the record) for the "isFolder" column/field.

    However, when I put the above into SmartGWT, and I used SmartGWT Dev Console to look at the RawResponse to the DSRequest. I noticed that value of "isFolder" was false for every record, even when it should have been "true" (according to the DB value).

    Code:
    {
        affectedRows:0, 
        data:[
            {
                ...
                isFolder:false, 
                ...
            }, 
            {
                ...
                isFolder:false, 
                ...
            }, 
            ...
        endRow:14, 
        invalidateCache:false, 
        isDSResponse:true, 
        operationType:"fetch", 
        queueStatus:0, 
        startRow:0, 
        status:0, 
        totalRows:14
    }
    As a test, I then changed my select clause and hard coded the value to be true for every record

    Code:
        ...
        <fields>
            ...
            <field name="isFolder" type="boolean"    title="Is Folder" required="true"   />
        </fields> 
        <operationBindings>
            <operationBinding   operationType="fetch"  >
                <selectClause>
                    ...
                    , true as isFolder
                    -- , if(treeNodeType='FOLDER', true, false) as isFolder
    
                    ...
    But still I saw that in RawResponse, all the value for isFolder was returned as false. It looks to me somehow the server side SmartGWT hard-coded the value for isFolder and ignore what the DB told it. Could this be a bug on the server side?

    SmartClient Version: v10.0p_2015-06-28/PowerEdition Deployment (built 2015-06-28)

    I was using Firefox (26.0)

    There were no error/warning messages from the server log. But here is the version string

    === 2015-08-31 16:29:48,872 [main] INFO ISCInit - Isomorphic SmartClient/SmartGWT Framework (v10.0p_2015-06-28/PowerEdition Deployment 2015-06-28) - Initialization Complete

    #2
    At a guess we suspect this is a server-side issue and is unrelated to ResultTree per-se.
    We would suspect that what's actually happening is that your custom server side logic is failing to run or failing to apply the property as you expect.

    If this is the case, you would see the same values in your fetch response if the fetch was initialized from a simple DataSource.fetchData() call on the client (or a ListGrid fetch or similar), and also if you changed your field name from "isFolder" to something else, the behavior would be unchanged, eliminating the possibility of it being anything hardcoded to return explicit false for that property.

    There should already be some server side logging around the fetch request which will indicate what the SQL Statement that was actually executed looks like. This may make it obvious whether your customized operation is being executed as expected.
    You can also look at the response either in the developer console "RPC" tab, or by modifying the log4j config settings on the server to have SQLDataSource and DSResponse categories be set to "debug" rather than "info".

    This may give you a better idea of what's going on. If it doesn't clarify things and you suspect there is a framework issue here, please let us know and we'll take another look.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi, in my ds.xml file, I changed the field name from "isFolder" to "isFolderA" -- just to make sure that file is being actively used.

      From the server log, I could see this query being run -- isFolderA is now hard-coded to value true

      Code:
      === 2015-09-01 09:39:47,153 [1-38] INFO  SQLDriver - [builtinApplication.naraRepoDS_fetch] Executing SQL query on 'central_aware_db_4100': SELECT
                      tnId
                      , parentId
                      , name
                      , true as isFolderA
                      -- , if(treeNodeType='FOLDER', true, false) as isFolder
                      , treeNodeType
                      , 'dummy' as dummy
                      , wbXmlString
                      , permissionXmlString
                   FROM
                      nara_db.leecy_repo
                   WHERE ('1'='1')
      But still in SmartGWT Dev Console, the Raw Response was this -- isFolder is hard-coded to value false

      Code:
      {
          affectedRows:0, 
          data:[
              {
                  parentId:1, 
                  tnId:1, 
                  name:"NARA", 
                  isFolderA:false, 
                  dummy:"dummy", 
                  treeNodeType:"FOLDER"
              }, 
              {
                  parentId:1, 
                  tnId:2, 
                  name:"leecygui", 
                  isFolderA:false, 
                  dummy:"dummy", 
                  treeNodeType:"FOLDER"
              }, 
              ...
          ], 
          endRow:14, 
          invalidateCache:false, 
          isDSResponse:true, 
          operationType:"fetch", 
          queueStatus:0, 
          startRow:0, 
          status:0, 
          totalRows:14
      }
      Your API has a method to set the (default) value for isFolder (ResultTree.setDefaultIsFolder()). I suspect some code is not done right that it uses the default (false in this case) and hard-codes it into Raw Response (until some time later, after it detects the number of children of a node)

      If you give me a private contact address, I can send you the full *.ds.xml file as well as the schema of the DB table. My email is leeyuiwah AT gmail DOT com. I have a support contract with Isomorphic

      Comment


        #4
        If what you're saying is correct and the server is setting your property ("isFolderA" now) to true, but it's ending up being "seen" as false in the client, the issue would appear to be on the client side, so we'd probably need to see client side code to reproduce the problem rather than just your DataSource definition.

        Obviously it wouldn't make sense for us to attempt to debug your full application.

        Probably the best way to proceed is this: Create a small test case consisting of
        - a simplified DS based on your ds but with just a few fields -- primary key, id / parentid field, and your isFolder field should be sufficient
        - a minimal EntryPoint class that mimics just the client side code involved in this particular fetch. So an onModuleLoad() which simply builds the equivalent UI (probably just a TreeGrid bound to the DataSource in question) and runs the appropriate "fetch" or "filter" call which is leading to this bad state.

        This should reproduce the problem you're seeing and be small enough for us to easily debug (while also eliminating the possibility of seemingly unrelated application code causing the problem in your actual usage).
        You can post this here - the content of the DS file and the EntryPoint would be sufficient, or if you would rather keep it off the public forum you could send it to support@isomorphic.com. (we monitor this email address for exactly this kind of communication).

        If for some reason the problem does NOT occur with your simplified test case this is actually progress! It indicates that the problem is elsewhere in your application and the next step would be for you to attempt to isolate what's special about the app that leads to this behavior. This may reveal an unexpected coding issue in the application, or a framework problem with the particular configuration you are using which isn't immediately obvious in a simpler setup.

        Regards
        Isomorphic Software

        Comment


          #5
          Hi,

          My client code is really simple (as of now I am just exploring the idea so the code is not the final one yet)

          Code:
              public void mockUpRepo() {
                  final TreeGrid repoTree = new TreeGrid();
          
                  repoTree.setLoadDataOnDemand(false);
                  repoTree.setWidth(winWidth);
                  repoTree.setHeight(winHeight);
                  repoTree.setAutoFetchData(true);
                  DataSource datasource = DataSource.get("myDS");
                  repoTree.setDataSource(datasource);
                  repoTree.setShowConnectors(true);
                  repoTree.setShowOpenIcons(true);
                  repoTree.setShowDropIcons(false);           
                  repoTree.setFields(new TreeGridField("name")
                                     , new TreeGridField("isFolder"));
                  
                  vLayout.addMember(repoTree);
              }

          Comment


            #6
            Hi leeyuiwah, Hi Isomorphic,

            Originally posted by Isomorphic View Post
            If what you're saying is correct and the server is setting your property ("isFolderA" now) to true, but it's ending up being "seen" as false in the client, the issue would appear to be on the client side, so we'd probably need to see client side code to reproduce the problem rather than just your DataSource definition.
            leeyuiwah showed the Developer Console output (false), so the problem is before the data gets to the widget IMHO.

            As boolean as column-type is not widely supported in RDBMS (see also the wikipedia entry) I'd try sth else first that rules out boolean problems at JDBC or Database level:
            Code:
            <fields>
               ...
               <field name="isFolder" [B]sqlStorageStrategy="singleCharYN"[/B] type="boolean" required="true" />
            </fields> 
                <operationBindings>
                    <operationBinding   operationType="fetch"  >
                        <selectClause>
                            ...
                            , 'Y' as isFolder
                            -- , if(treeNodeType='FOLDER', true, false) as isFolder
            
                            ...
            What's the Developer's Console RPC Tab Output for this .ds.xml?

            Best regards
            Blama

            Comment


              #7
              Hi Blama
              Thanks for weighing in - this is a good point and the suggestion is worth trying.

              FYI - The dev console RPC tab does indeed show the raw response from the server so would be expected to be unaffected by downstream processing by the client code. However we wanted a complete test case in case something unexpected was happening like the response data being updated directly (by reference) causing the dev console to show modified data, etc. This is actually unlikely but something we felt we should rule out. In short a full test case gives us a way to analyze the problem on our end.

              However, Leeyuiwah - Blama's suggestion is a good one - does switching to the "Y" / "N" storage strategy and populating your response with a "Y" have any impact on the issue in your environment?

              Regards
              Isomorphic Software

              Comment


                #8
                Just to add to this: from the screenshots you emailed to us, it seems clear that you expect boolean true values to end up in the database as '1', and boolean false as '0'. Using a sqlStorageStrategy of "singleCharYN" will not achieve this; instead, you should use an sqlStorageStrategy of either 'integer' or 'singleChar10', depending on the type of the underlying column. If you are using the MySQL-specific "BOOL" or "BOOLEAN" column types, they are just syntactic sugar - the underlying column type is "TINYINT", and a sqlStorageStrategy of "integer" will have the desired effect.

                Regards,
                Isomorphic Software Support

                Comment


                  #9
                  Hi Blama & Isomorphic

                  Indeed the problem could be solved by setting sqlStorageStrategy="integer" for the two isFolder fields (we are using MySQL). That is

                  Code:
                  <field name="isFolderA" type="boolean"    title="Is Folder A" 
                         required="true"  
                         width="200" 
                         sqlStorageStrategy="integer" />
                  <field name="isFolder" type="boolean"    title="Is Folder" 
                         required="true"  
                         width="200" 
                         sqlStorageStrategy="integer" />

                  Thanks a lot for the help!

                  Comment

                  Working...
                  X