0

我有一个PresentationModelAS 类,其中包含SomeView.mxml. 模型的整个类都是可绑定的,视图中的模型属性也是可绑定的。但是,我无法使用PropertyInjector标签将模型注入到视图中:

- INFO: Data binding will not be able to detect assignments to model

熟悉 Flex 数据绑定和 Mate 的人可以帮帮我吗?非常感谢!

MainEventMap.mxml

<EventHandlers type="{FlexEvent.INITIALIZE}">
    <ObjectBuilder generator="{PresentationModel}" registerTarget="true">
        <Properties dispatcher="{scope.dispatcher}"/>
    </ObjectBuilder>
</EventHandlers>


<Injectors target="{SomeView}" debug="true">
    <PropertyInjector targetKey="model" source="{PresentationModel}" />
</Injectors> 

片段来自PresentationModel.as

[Bindable]
public class PresentationModel extends EventDispatcher
{
    public var dispatcher:IEventDispatcher;

    //.....other variables and functions
}

片段来自SomeView.mxml

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="518" height="562" >
<mx:Script>
    <![CDATA[

         //...... all the imports

        [Bindable]
        public var model:OSGiBrokerConsoleModel;

        // ......other variables and functions
    ]]>
</mx:Script>

    // ..... actual view components

</mx:Canvas>
4

2 回答 2

1

您可以放心地忽略该信息消息。

当您有一个带有源和源键的 PropetyInjector 时,通常会显示该消息,其中“sourceKey”定义的属性不可绑定,因此我们要确保您知道该属性的当前值将是唯一的目标值将永远得到(当属性不可绑定时,复制该值并且不建立绑定)。这可能是也可能不是你想要的。

在这种情况下,没有 sourceKey,因为您不想绑定到源的任何特定属性。相反,您希望将整个 PM 传递给视图。因此,您不想建立绑定,只需将值发送到视图一次。

在没有 sourceKey 或您只是发送一次性值的情况下(即:当您发送常量时),可以忽略该消息。

于 2009-12-23T04:29:28.623 回答
0

你不能绑定到一个类。使一个类可绑定意味着该类的所有成员都是可绑定的,但不是定义本身。

您应该为返回要用作源的数据的表示模型创建一个成员函数(getter/setter)。然后,您还需要创建一个可以用于绑定的 PresentationModel 实例。因此,与其绑定到 PresentationModel.data,不如绑定到 myPM.data。

于 2009-11-03T11:02:40.077 回答