Skip to Content
avatar image
Former Member

Calling firePropertiesChanged on load fail

Hi all,

I am trying to get some information of a result set in the shape of a component. The functionality is provided by the excellent Community Package, see: https://github.com/org-scn-design-studio-community, however, I do not want to overload my users with all of the components provided by it. On top of that I believe the code needed to get the functionality we need could be quite little.

The problem I face has to do with what seems to be the internal caching mechanism DS components have between the client run-time environment and the JS logic that is executed on the server.

When I update the data property, I want to make sure that the client side is aware that the number of rows now has been updated as well. However I am unable to do that. It just keeps showing the default value.


Can anybody tell me how the firePropertiesChanged method is supposed to work? And what is going wrong here?


See the code to the component attached. I am using DS15SP2.


Kind regards,

Attila

//var ResultSetInfo = function () {
 sap.designstudio.sdk.Component.subclass("blah.ResultSetInfo", function() {
  var _data;
  var _numberOfRows;

    this.init = function () {
    console.log("init");
    }


    this.beforeUpdate = function () {
    console.log("beforeUpdate called _numberOfRows var", _numberOfRows);
    };


    this.afterUpdate = function () {
    console.log("afterUpdate called _numberOfRows var", _numberOfRows);
    };


    this.data = function (value) {
    console.log("data (g/s)etter arg", value);
   
        if (value === undefined) {
            return _data;
        } else {
            _data = value;
            return this;
        }
    };
    
    this.resetInfo = function(value) {
    console.log("resetInfo arg", JSON.stringify(value), "resetting the numberOfRows and firing changes");
   
    _numberOfRows = _data["axis_rows"].length;
    this.firePropertiesChanged(["numberOfRows"]);
    }


    this.numberOfRows = function (value) {
    console.log("numberOfRows (g/s)etter arg", JSON.stringify(value));
   
    if (value === undefined) {
    return _numberOfRows;
    } else if (value === "<reset>"){
    // Does not work. It seems we need to still try the firePropertiesChanged method. Yet that does not work.
    _numberOfRows = _data["axis_rows"].length;
    return this;
    } else {
    _numberOfRows = value;
    return this;
    }
    };
// INDEPENDENTDEVELOPMENT:
//};
 });
<?xml version="1.0" encoding="UTF-8"?>
<sdkExtension
  xmlns="http://www.sap.com/bi/zen/sdk"
  title="ResultSetInfo"
  version="1.0"
  vendor="Blah"
  id="blah.resultsetinfo">

  <component
  databound="true"
  icon="res/icon.png" 
  id="ResultSetInfo"
  handlerType="div"
  title="ResultSetInfo">

  <jsInclude>res/js/component.js</jsInclude>

  <property id="data" title="Data Series" type="ResultSet" group="DataBinding"/>
  <property id="resetInfo" title="For resetting the info" type="String" group="Display" visible="false"/>
  <property id="numberOfRows" title="Number of rows" type="int" group="Display" visible="false"/>

  <initialization>
  </initialization>
  </component>
</sdkExtension>
class blah.ResultSetInfo extends Component {

  int getNumberOfRows() {*
  this.resetInfo = Math.random();
  return this.numberOfRows;
  *}
}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 29, 2015 at 07:17 AM

    Hi Attila,

    One quick question .Why do you need this.resultInfo() ? you can use afterUpdate() for updating the getter&setter . i just re-ordered the code. Hope this might help.

    sap.designstudio.sdk.Component.subclass("blah.ResultSetInfo", function() {
    
    
      var _data;  
       var _numberOfRows;  
         this.init = function () {  
         console.log("init");  
         }  
         this.beforeUpdate = function () {  
         console.log("beforeUpdate called _numberOfRows var", _numberOfRows);  
         };  
         this.afterUpdate = function () {  
         
         _numberOfRows = _data["axis_rows"].length;  
         this.firePropertiesChanged(["numberOfRows"]);  
         console.log("afterUpdate called _numberOfRows var", _numberOfRows);  
         };  
         this.data = function (value) {  
         console.log("data (g/s)etter arg", value);  
          
             if (value === undefined) {  
                 return _data;  
             } else {  
                 _data = value;  
                 return this;  
             }  
         };  
           
         this.resetInfo = function(value) {  
         console.log("resetInfo arg", JSON.stringify(value), "resetting the numberOfRows and firing changes");  
          
         
         }  
         this.numberOfRows = function (value) {  
         console.log("numberOfRows (g/s)etter arg", JSON.stringify(value));  
          
         if (value === undefined) {  
         return _numberOfRows;  
         } else if (value === "<reset>"){  
         // Does not work. It seems we need to still try the firePropertiesChanged method. Yet that does not work.  
         _numberOfRows = _data["axis_rows"].length;  
         return this;  
         } else {  
         _numberOfRows = value;  
         return this;  
         }  
         };  
      // INDEPENDENTDEVELOPMENT:  
      //};  
      });  
    

    And to answer your question firePropertiesChanged is used to update values .the changesyou made in component.js/additonal-prop.js  will get updated in component.js/additional-prop.js/contribution.ZTL .


    Thanks

    Naveen.


    firePropertiesChanged

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Attila ,

      Am glad it worked 😊

      Basically the afterUpdate() will trigger when any setter get updated or modified. so use afterUpdate() for the updating the setter .

      Thanks

      Naveen