Announcement

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

    Bug when setting relatedData in a DMI?

    Hi,

    there seems to be a problem with manipulating data in a DMI as described here when related data is involved:
    Originally posted by Isomorphic View Post
    The DMI approach means you simply declare fields normally, then add DMI logic to your "fetch" operation where you call the server-side DSResponse.getRecord()s and convert all the Long values to Strings, then call DSResponse.setData() with the updated data.
    I tried to do this but get
    Code:
    Couldn't get value for property 'country' for datasource 'cityManyToOneSimpleHB' - ignoring. Actual error: java.lang.Exception: Specified object is not instance of com.smartgwt.sample.showcase.server.CityManyToOneSimple
    and the related field is not appearing.

    For demoing this (this is also where above exception is from), I just took this example
    http://www.smartclient.com/smartgwtee/showcase/#hbRelationManyToOneSimple

    and added the following CitiesDMI.java
    Code:
    package com.smartgwt.sample.showcase.server;
    
    import java.util.List;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    import com.isomorphic.log.Logger;
    
    public class CitiesDMI {
    
        Logger log = new Logger(CitiesDMI.class.getName());
    
        public DSResponse fetch(DSRequest dsRequest) throws Exception  {
            log.info("processing DMI fetch operation");
    
            DSResponse dsResponse = dsRequest.execute();
            List data = dsResponse.getRecords();
            dsResponse.setData(data);
            return dsResponse;
        }
    
    }
    To invoke the DMI I added

    Code:
     <serverObject className="com.smartgwt.sample.showcase.server.CitiesDMI"/>
    to cityManyToOneSimpleHB.ds.xml.
    When the page is loaded (and the data fetched using the DMI), above exception is thrown.
    If dsResponse.setData(data); is outcommented, everything works as expected.

    This happens for the showcase of
    Version: 4.0p (built Fri Aug 23 10:02:00 GMT 2013)
    but also in my productive environment
    SmartClient Version: v8.3p_2013-09-25/PowerEdition Deployment (built 2013-09-25)

    Thanks,
    fatzopilot

    #2
    Thanks for pointing this out. The logic that processes HB relation fields was indeed still being attempted even though you substituted a List of Maps for the data.

    This should be fixed back to 8.3 for the next nightly build - it would be great if you could confirm the fix.

    Comment


      #3
      fatzopilot, hi again,

      this was reviewed and actually this is not a problem at all. In your sample everything functions as it is supposed to.

      The solution for you would be to use dsResponse.getDataList() instead of dsResponse.getRecords(), like shown below:
      Code:
      package com.smartgwt.sample.showcase.server;
      
      import java.util.List;
      
      import com.isomorphic.datasource.DSRequest;
      import com.isomorphic.datasource.DSResponse;
      import com.isomorphic.log.Logger;
      
      public class CitiesDMI {
      
          Logger log = new Logger(CitiesDMI.class.getName());
      
          public DSResponse fetch(DSRequest dsRequest) throws Exception  {
              log.info("processing DMI fetch operation");
      
              DSResponse dsResponse = dsRequest.execute();
              [b]List data = dsResponse.getDataList();[/b]
              dsResponse.setData(data);
              return dsResponse;
          }
      
      }

      Comment

      Working...
      X