Q:

Google apps script: How to place function called by handler inside object?

I create an object that returns textBox(), which could change their properties depending on the user's actions. However, once I put the function doChange(e) inside the object as a method like this:
function textBoxExt() {
...
  this.doChange = function(e) {...}
...
}

my code returns an error: Cannot find a function doChange()...
I tried different ways to declare a function as a method in my object, but none of them worked. Please tell me, how do I modify the code below to move doChange(e) inside the object as a method. It is possible for functions that calls by handlers?
var style = {
  modified: {color: 'black', backgroundColor: 'yellow', },
};

function textBoxExt() {
  var app = UiApp.getActiveApplication();
  var changeHandler = app.createServerHandler('doChange');
  var box = app.createTextBox();
  box.addValueChangeHandler(changeHandler);

  this.init = function(id) {
    return box.setId(id);
  }
}

var doChange = function(e){
  var app = UiApp.getActiveApplication();
  app.getElementById(e.parameter.source).setStyleAttributes(style.modified);
  return app;
  }

function doGet() {
  var app = UiApp.createApplication();
  app.add(new textBoxExt().init('box1').setText('text1'));
  return app;
}

A:

You cant do this with gas. Handlers are passed as text. Besides objects only exist during the current handler so it cant possibly be attached to an object from a previous server call.

