0

我从 Parsley 开始,无法使自动接线工作。我的配置基于 flex 4.5 和 parsley 3.0.0。

我的应用程序包含以下引导程序:

<fx:Declarations> 
    <parsley:ViewSettings autowireComponents="true"/> 
    <parsley:ContextBuilder config="{SimulateurConfig}" /> 

    <s:TraceTarget 
            includeCategory="true" 
            includeLevel="true" 
            includeTime="true" 
            level="{LogEventLevel.DEBUG}" 
            > 
        <s:filters> 
            <fx:String>org.spicefactory.parsley.*</fx:String> 
        </s:filters> 
    </s:TraceTarget> 
</fx:Declarations>

配置非常简单:

<fx:Declarations> 
    <View type="com.coach.ui.PanelAFinancer"/> 
    <Object type="com.coach.domain.AFinancer" /> 
</fx:Declarations> 

我的面板包含:

<fx:Script><![CDATA[ 
    import com.coach.domain.AFinancer; 

    [Bindable] [Inject] 
    public var model:AFinancer; 
    ]]></fx:Script> 


<s:Label text="Model injected? { model != null }"/> 

我认为我做的一切都是正确的,但模型并没有注入我的视野。跟踪表明:

[trace] 12:49:12.186 [INFO] org.spicefactory.parsley.core.state.manager.impl.DefaultGlobalDomainManager Using new ApplicationDomain for key [object _Flex_simulateur_mx_managers_SystemManager] 
[trace] 12:49:12.218 [INFO] org.spicefactory.parsley.core.view.impl.DefaultViewManager Add view root: Flex_simulateur0/Flex_simulateur 
[trace] 12:49:12.218 [INFO] org.spicefactory.parsley.core.bootstrap.impl.DefaultBootstrapManager Creating Context [Context(FlexConfig{SimulateurConfig})] without parent 
[trace] 12:49:12.296 [INFO] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Configure managed object with [ObjectDefinition(type = com.coach.domain::AFinancer, id = _SimulateurConfig_MxmlRootObjectTag1)] and 0 processor(s) 

没有视图处理的迹象。

如果我在面板中添加«手动配置»:

<fx:Declarations> 
    <sf:Configure/> 
</fx:Declarations> 

注入工作:

[trace] 12:56:04.983 [INFO] org.spicefactory.parsley.core.state.manager.impl.DefaultGlobalDomainManager Using new ApplicationDomain for key [object _Flex_simulateur_mx_managers_SystemManager] 
[trace] 12:56:05.015 [INFO] org.spicefactory.parsley.core.view.impl.DefaultViewManager Add view root: Flex_simulateur0/Flex_simulateur 
[trace] 12:56:05.030 [INFO] org.spicefactory.parsley.core.bootstrap.impl.DefaultBootstrapManager Creating Context [Context(FlexConfig{SimulateurConfig})] without parent 
[trace] 12:56:05.124 [INFO] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Configure managed object with [ObjectDefinition(type = com.coach.domain::AFinancer, id = _SimulateurConfig_MxmlRootObjectTag1)] and 0 processor(s) 
[trace] 12:56:05.140 [DEBUG] org.spicefactory.parsley.core.view.handler.ViewConfigurationHandler Process view 'Flex_simulateur0.ApplicationSkin3._ApplicationSkin_Group1.contentGroup.viewRoot.PanelAFinancer7' with [Context(FlexConfig{SimulateurConfig})] 
[trace] 12:56:05.155 [INFO] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Configure managed object with [ObjectDefinition(type = com.coach.ui::PanelAFinancer, id = _SimulateurConfig_MxmlViewTag1)] and 1 processor(s) 
[trace] 12:56:05.155 [DEBUG] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Applying [Property(name=[Property model in class com.coach.ui::PanelAFinancer],value={ImplicitTypeReference(type=undefined)})] to managed object with [ObjectDefinition(type = com.coach.ui::PanelAFinancer, id = _SimulateurConfig_MxmlViewTag1)] 
[trace] 12:56:05.171 [DEBUG] org.spicefactory.parsley.core.view.processor.DefaultViewProcessor Add view 'Flex_simulateur0.ApplicationSkin3._ApplicationSkin_Group1.contentGroup.viewRoot.PanelAFinancer7' to [Context(FlexConfig{SimulateurConfig})] 

解决方法非常繁重,因为它需要在我的所有视图中添加专有标签。

知道我的配置有什么问题吗?

4

1 回答 1

0

我建议您使用其他解决方案。当您配置(或连接)视图时,Parsley 需要反映该类并遍历所有属性以找到注入点。这是昂贵且耗时的。可能只适用于几个有线视图,但通常情况并非如此,因为如果您使用 Flex 和 Parsley,您很有可能会拥有很多视图。

更好的方法是在 parsley 配置中创建所有模型、演示者、服务等,不包括所有视图。在视图中,您只需要这样使用 FastInject 标记:

<fx:Declarations>
    <spicefactory:FastInject property="model" type="{AFinancer}" /> 
</fx:Declarations>
<fx:Script><![CDATA[ 
    import com.coach.domain.AFinancer; 

    [Bindable]
    public var model:AFinancer; 
]]></fx:Script> 

这是一种更好的方法,因为不需要反射。唯一的“问题”是您不能在视图中使用 Parsley 元数据,这更好地将业务关注点与视图分开。这也有助于您在整个应用程序中重用演示者并帮助测试所述演示者。

于 2012-03-12T16:48:07.257 回答