How to use classes defined with qxoo with nodejs?

Problem

var qx = require('qooxdoo');
var t= new T(4080);
var t= new qx.T(4080);
// none of them are defined :s

I have my main file, run.js and then a file T.js with a class:

qx.Class.define("T", {
    extend : qx.core.Object,

    constructor: function(port){
        debugger;
        var self = this;
        this.port = port;
        this.server = http.createServer(function(req, res){
            self.onRequest.apply(self, arguments);
        });
        server.listen(port);
    },

    members : {
        onRequest: function(req, res){
            debugger;
            util.log('requested!');
        }
    }
 });

I'm missing something?

http://manual.qooxdoo.org/1.6/pages/server/overview.html Here they don't say how to use other files, only in the same file.. so I don't really know how to do..

any help is very appreciated, thanks (:

Problem courtesy of: Totty.js

Solution

You are missing the part where you run the T.js file (by requiring it). For example something like this works:

app.js:

var qx = require('qooxdoo');
require('./class-t'); // Run the file that creates the class.

var t = new T();
t.foo(); // logs "T#foo called"

class-t.js:

var qx = require('qooxdoo');

qx.Class.define('T', {
  extend: qx.core.Object,

  members: {
    foo: function () {
      console.log('T#foo called');
    }
  }
});
Solution courtesy of: Felix Loether

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.