2012-03-12 14 views
0

パーズリーからはじまり、オートワイヤーを機能させることはできません。私の設定は、flex 4.5とパセリ3.0.0に基づいています。パーズリー自動配線が動作しない

私のアプリケーションはfolowing bootrapが含まれています

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

そして、私のパネルが含まれています:

<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: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})] 

それはすべて私の意見では、独自のタグを追加する必要として、回避策はかなり重いです。

私の設定に何が間違っているのか考えてみましょうか?

答えて

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メタデータを使用できないことです。これは、ビジネス上の問題をビューから分離するのに適しています。これにより、アプリケーション全体でプレゼンターを再利用したり、プレゼンターのテストを手助けすることもできます。

+0

これはうまくいくかもしれませんが、私の問題は、パースリーに依存しないクリーンなビューを持つことでした。私はいつもIoCを使うのは迷惑で、コード内で多くのフレームワーク設定が必要です。 http://www.spicefactory.org/parsley/docs/3.0/manual/view.php#config_automaticの最初の文は、動作するはずであることを示しています。 – GaetanZ

+0

はい、そうすることができるはずです。クラスの文字列を指定する代わりに、クラスを直接バインドしてみてください。 ''どのように画面にビューを追加していますか? –

+0

新しいmxmlタグはありません。 – GaetanZ

関連する問題