0

私はパセリから始めていますが、自動配線を機能させることができません。私の構成は、flex 4.5 と parsley 3.0.0 に基づいています。

私のアプリケーションには、次の bootrap が含まれています。

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

ビュー処理の兆候はありません。

パネルに «manual configuration» を追加すると:

<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 を使用している場合は、多数のビューが存在する可能性が高いため、通常はそうではありません。

より良いアプローチは、すべてのビューを除外して、パセリ構成ですべてのモデル、プレゼンター、サービスなどを作成することです。ビューでは、次のように 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 に答える