Announcement

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

    Getting/Reading values in callback

    Isomorphic,

    I am invoking a method using a data source and trying to get the data from this DMI through callback as shown Below.

    Code:
            DataSource dataSource = DataSource.get("dateRange");
            DSRequest dataRequest = new DSRequest();
            dataSource.fetchData(createCriteria(), new DSCallback() {
                @Override
                public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
                    Record r = dsResponse.getData()[0];
                    String userName= r.getAttributeAsString("userName");
                    String host = r.getAttributeAsString("host");
                }
            }, dataRequest);
    In my DMI, i am actually setting the data by creating an object of class UserInfo as shown below.

    Code:
    UserInfo objUserInfo = new UserInfo();
    objUserInfo.setUserName("ABC");
    dsResponse.setData(objUserInfo);
    return dsResponse;
    Code:
    public class UserInfo {
        private String userName;
        private String host;
     public String getUserName() {
            return userName;
        }
    
        public void setUserName(String userName) {
            this.userName = userName;
        }
     public String getHost() {
            return host;
        }
    
        public void setHost(String host) {
            this.host = host;
        }
    }

    I tried all getAttribute functions to retrieve user names, but none of them are giving me the correct user name and host.

    Let me know how can i achieve this.

    #2
    Take a look at the RPC tab in the Developer Console. If those getAttribute() calls aren't working it probably means you are returning blank data.

    Comment


      #3
      I had a look at RPC tab. It says the status is successful.

      dsResponse.setData(userInfo); Here i have 2 properties set in userInfo object.

      How can i check getAttribute() calls are working fine or not in RPC tab?

      Comment


        #4
        Post the actual contents of the RPC tab here.

        Comment


          #5
          RPC Request tab
          Code:
          {
              "actionURL":"http://127.0.0.1:8888/MarketIntelligence/sc/IDACall", 
              "showPrompt":false, 
              "transport":"xmlHttpRequest", 
              "promptStyle":"cursor", 
              "bypassCache":true, 
              "data":{
                  "criteria":{
                      "USERNAME":"sg206965", 
                      "PASSWORD":"Sabre123"
                  }, 
                  "operationConfig":{
                      "dataSource":"dateRange", 
                      "repo":null, 
                      "operationType":"fetch"
                  }, 
                  "appID":"builtinApplication", 
                  "operation":"dateRange_fetch", 
                  "oldValues":{
                      "USERNAME":"sg206965", 
                      "PASSWORD":"Sabre123"
                  }
              }
          }
          Response-Raw tab

          Code:
          [
              {
                  queueStatus:0, 
                  isDSResponse:true, 
                  invalidateCache:false, 
                  status:0, 
                  data:{
                  }
              }
          ]
          Do i need to set cache true?

          Comment


            #6
            As suspected, you are not sending data back. Show your DataSource definition - have you actually declared the fields you are trying to send back? See also DataSource.dropExtraFields.

            Comment


              #7
              Code:
              <DataSource ID="dateRange" table="CLIENT_VALID_DATES" serverType="sql" dbName="Oracle" showPrompt="false" qualifyColumnNames="false">
                  <field name="userName" type="text" required="false" title="userName"/>
                  <field name="host" type="text" required="false" title="host"/>
                  <serverObject lookupStyle="new" className="com.sabre.apd.mi.smartgwt.server.SsoUser"/>
              </DataSource>
              This is my DataSource. Let me know what is wrong!!

              Comment


                #8
                The only problem with any of the code shown here is that you should technically call setData() with your UserInfo object contained in a single-element List. If that's not the issue, work toward a standalone test case we can run to see the problem.

                Comment


                  #9
                  Did you mean the object of UserInfo should have only one data member as a list/Map??

                  As of now, i have two data member(userName and host)

                  Comment

                  Working...
                  X