1

qooxdooフレームワークを使用する場合、クラス内:(.xmlファイルではactiveRowは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>

これは機能します:

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

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

これは動作しません:

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

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

構文のどの部分が間違っているか誰かが知っていますか?

前もって感謝します!

以下の議論を含む追加:

alert(typeof this.getActiveRow); 戻り値:関数

alert(this.getActiveRow);

戻り値:

function(){
return qx.core.Property.executeOptimizedGetter(this, bI, name, "get");
}
4

2 に答える 2

1

このより完全なPlaygroundの例を見てください(コードを試すこともできます)。コード自体は次のとおりです。

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());

'init'のあるプロパティとないプロパティ、およびプロパティ全体、またはプロパティのオブジェクトのメンバーのみを取得するコードスニペットをキャプチャします。私にとっては、すべて期待どおりに機能します。「setAndGet」メソッドで使用するthis.setActiveRow(123)と、「オブジェクト型の期待値ですが、123を取得しました」などの適切なエラーメッセージが表示されます(ログペインに表示されます)。

于 2011-03-20T16:37:48.160 に答える
0

最初のサンプルが機能する場合は、setActiveRowメソッドが引数として整数を期待していることを意味するため、連想配列を渡す{test1: 123, test2: 123 }と破損している可能性があります。

したがって、最初のサンプルにあるようなコードを用意します。

this.setActiveRow(123);

test1次に、クラスのプロパティであると仮定すると、2行目は正常に機能するはずです。

于 2011-03-14T15:33:34.090 に答える