1

In use of the qooxdoo framework, in a class: (in the .xml file activeRow is defined as an object_iterate: )

        <object_literal name="activeRow" scope="static" constructor="false" deprecated="false" private="false" protected="false" ignored="true" internal="false" type="Object">
            <property name="nullable" scope="static" constructor="false" deprecated="false" private="false" protected="false" ignored="true" internal="false" type="Boolean">
            </property>
            <property name="check" scope="static" constructor="false" deprecated="false" private="false" protected="false" ignored="true" internal="false" type="String">
            </property>
        </object_literal>

this DOES work:

properties: {
        activeRow: {            
            nullable: true,
            check: "Object"
        },
...

this.setActiveRow(123);
var x = this.getActiveRow();

this DOES NOT work:

properties: {
        activeRow: {            
            nullable: true,
            check: "Object",
        init: {test1: null, test2: null}
        },
...

this.setActiveRow({test1: 123, test2: 123 });
var y = this.getActiveRow().test1;

Does anyone know which part of the syntax is wrong?

Thank you in advance!

Addition containing discussion below:

alert(typeof this.getActiveRow); returns: function

alert(this.getActiveRow);

returns:

function(){
return qx.core.Property.executeOptimizedGetter(this, bI, name, "get");
}
2
  • The last comma should be removed -> check: "Object", Commented Mar 14, 2011 at 15:26
  • ahgood is correct in the first example that there are too many commas. However, you state that the first example is working. It is not possible to tell what's wrong based on your limited code pastes. We cannot see what setActiveRow and getActiveRow actually do and/or return. We also cannot see in what scope they're defined. Commented Mar 14, 2011 at 15:26

2 Answers 2

1

Take a look at this more complete Playground example (where you can also experiment with the code). Here is the code itself:

qx.Class.define("Foo", {
    extend: qx.core.Object,
    properties: {
      activeRow: {
        nullable : true,
        check: "Object"
      },
      activeRowInit: {
        nullable : true,
        check: "Object",
        init: {test1: null, test2: null}
      }
    },
    members : {
      setAndGet : function () {
        this.setActiveRow({a:1,b:2});
        /*this.setActiveRow(123);*/
        var x = this.getActiveRow();
        return x;
      },
      setAndGetMember : function () {
        this.setActiveRowInit({test1: 123, test2: 123 });
        var y = this.getActiveRowInit().test1;
        return y;
      }
    }
});
var f = new Foo();
alert(f.setAndGet());
alert(f.setAndGetMember());

It captures your code snippets, with a property with and one without 'init', and with getting the whole property, or just a member of the property's object. For me, it all works as expected. If you use this.setActiveRow(123) in the "setAndGet" method, you get a reasonable error message saying something like "expected value of type object but got 123" (in the log pane).

Sign up to request clarification or add additional context in comments.

1 Comment

problem solved: I had to pass the context, as you said the get and set worked well itself. thank you!
0

If the first sample works it means setActiveRow method is expecting an integer as its argument, so probably passing the associative array {test1: 123, test2: 123 } is breaking it.

So have such code as you have in the first sample:

this.setActiveRow(123);

Then the second line should work fine assuming test1 is property of the class.

12 Comments

Qooxdoo does automatically build a set- and get for it,-which I could not find anywhere. It is just defined in the .xml-file as edited above, and than as property in the js class.
@N47 ok, what you mean exactly by "this DOES NOT work"? What happens? You get error?
I wanted to use this to carry two- instead of one data entries with this object.. my other solution would be an array which i fill in the object, but I thought this would not be the way its ment to be used.
@ shadow Wizard, firebug tells me "getActiveRow is not a function" when i run the site containing the script.
@N47 but you said "this DOES work" on your first sample that also contain getActiveRow call - so I'm bit confused here.. EDIT: in case of syntax error somewhere, the whole script block won't be loaded - you should see this in Firebug as well.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.