Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14881] Android: Getter and Setter not getting added for any new property on NativeObject

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.1.2
Fix Version/sn/a
ComponentsAndroid
Labelsqe-3.1.2
ReporterPriya Agarwal
AssigneeUnknown
Created2013-08-14T11:52:03.000+0000
Updated2018-02-28T20:03:58.000+0000

Description

Getter and Setter not getting added for any new property on NativeObject automatically where as it works fine on ios.
var win=Ti.UI.createWindow();
var myApp = {};
  
myApp.ui = {};
  
myApp.ui.createMyView = function() {
    var v = Ti.UI.createView({});
    v.foo = 100;
   
    v.getSomething = function() {
        return v.foo;
    };
 
    v.setSomething = function(val) {
        v.foo = val;
    }
      
    v.getFood = 200;
  
    return v;
};
  
var myView = myApp.ui.createMyView();
 
Ti.API.info(myView.getSomething);
Ti.API.info(myView.setSomething);
Ti.API.info(myView.getFood);
Ti.API.info(myView.getFoo);
 
Ti.API.info(myView.getSomething());
myView.setSomething(50);
Ti.API.info(myView.getSomething());
 
Ti.API.info(myView.getFoo());
myView.setFoo(10);
Ti.API.info(myView.getFoo());
win.open();
Expected Result: This is for ios: [INFO] [INFO] [INFO] 200 [INFO] [object TiUIView] [INFO] 100 [INFO] 50 [INFO] 50 [INFO] 10 Actual Result: On ios: [INFO] [INFO] [INFO] 200 [INFO] [object TiUIView] [INFO] 100 [INFO] 50 [INFO] 50 [INFO] 10 On android: Getting exception E/TiExceptionHandler(19656): (main) [1,11350] - In acceptance.js:668,22 E/TiExceptionHandler(19656): (main) [0,11350] - Message: Uncaught TypeError: Object # has no method 'getFoo' E/TiExceptionHandler(19656): (main) [1,11351] - Source: Ti.API.info(myView.getFoo());

Comments

  1. Federico Casali 2013-08-30

    Reproducible on Android device and simulator. Titanium SDK 3.1.3.v20130829174830 Appcelerator Studio 3.1.3.201308252005 CLI 3.1.2.GA Node 0.10.13 Also, fixed a small typo in the sample code: line 30:
       Ti.API.info(myView.getSomething())l
       
    changed to:
       Ti.API.info(myView.getSomething());
       

JSON Source