弹性+凯恩格姆 +绑定 VO 上的 getter setter

发布于 2024-08-07 17:55:59 字数 272 浏览 5 评论 0原文

我觉得这应该是一件简单的事情,但我在经过一番挫折后才提出这个问题。

好的,我正在 Flex 3 的 Cairngorm 中做一个项目。在其中一个组件中,我有一个绑定到模型定位器中 VO 的图块列表。一旦 VO 包含一些数据,我想运行一个函数,这些数据基本上将 VO 中的某个值相加。我在安娜堡的 Flex Jam 上,我认为詹姆斯用吸气剂和吸气剂做了这件事。二传手以凯恩戈姆为例。

这是一件简单的事情吗?有人有如何执行此操作的示例吗?有更简单的方法吗?

提前感谢您的任何帮助/建议。

I feel like this should be a simple thing, but here I am asking the question after a good amount of frustration.

Ok I have a project I'm doing in Cairngorm in Flex 3. In one of the components I have a tile list that's bound to a VO in a Model Locator. I want to run a function once that VO contains some data that basically adds sums a certain value in that VO. I was at the Flex Jam in Ann Arbor and I thought James did this with getters & setters with his Cairngorm example.

Is this a simple thing? Does anyone have an example of how to do this? Is there an easier way?

Thanks ahead of time for any help/advice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亢潮 2024-08-14 17:55:59

听起来他所做的是在 VO 中为集合属性添加一个 getter/setter,它根据新集合的内容重新计算总和值,即这是一个非常标准的方法,下面的代码并不困难。

private _yourCollection:ArrayCollection;

public function set yourCollection( value:ArrayCollection ):void
{
    if ( _yourCollection != value)
    {
        _yourCollection = value;
        // calculate new sum
        var sum:Number = 0;
        for each ( var obj:SomeVOType in _yourCollection )
            sum += obj.valueToSum;
        sumProperty = sum;
    }
}

It sounds like what he did was add a getter/setter for the collection property in the VO which recalculates that summed value based on the contents of the new collection, i.e. This is a pretty standard approach and the code below is not difficult.

private _yourCollection:ArrayCollection;

public function set yourCollection( value:ArrayCollection ):void
{
    if ( _yourCollection != value)
    {
        _yourCollection = value;
        // calculate new sum
        var sum:Number = 0;
        for each ( var obj:SomeVOType in _yourCollection )
            sum += obj.valueToSum;
        sumProperty = sum;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文