public class DelegatingNavigationHandlerProxy extends NavigationHandlerEE
faces-config.xml ファイルでこのハンドラープロキシを次のように構成します。
<application>
...
<navigation-handler>
org.springframework.web.jsf.DelegatingNavigationHandlerProxy
</navigation-handler>
...
</application> デフォルトでは、Spring ApplicationContext は、Bean 名 "jsfNavigationHandler" で NavigationHandler を検索します。最も単純なケースでは、これは次のような単純な Spring Bean 定義です。ただし、Spring の Bean 構成機能のすべて、特に依存性注入のすべてのフレーバーをこのような Bean に適用できます。<bean name="jsfNavigationHandler" class="mypackage.MyNavigationHandler"> <property name="myProperty" ref="myOtherBean"/> </bean>ターゲット NavigationHandler Bean は通常、標準の JSF NavigationHandler クラスを継承します。ただし、このようなシナリオでは、元の NavigationHandler(JSF プロバイダーのデフォルトハンドラー)の装飾はサポートされていないことに注意してください。これは、元のハンドラーを標準の JSF スタイルで(つまり、コンストラクター引数として)挿入できないためです。
元の NavigationHandler を装飾するには、ターゲット Bean が Spring の DecoratingNavigationHandler クラスを継承していることを確認してください。これにより、このプロキシが自動的に検出するメソッド引数として元のハンドラーを渡すことができます。DecoratingNavigationHandler サブクラスは引き続き標準の JSF NavigationHandler としても機能することに注意してください。
このプロキシは、ナビゲーションハンドラーの検索に使用される Bean 名の変更、ターゲットハンドラーの取得に使用される戦略の変更、または ApplicationContext へのアクセスに使用される戦略の変更(通常は FacesContextUtils.getWebApplicationContext(FacesContext) を介して取得)にサブクラス化できます。
DecoratingNavigationHandler| 修飾子と型 | フィールドと説明 |
|---|---|
static StringSE | DEFAULT_TARGET_BEAN_NAMESpring アプリケーションコンテキスト内のターゲット Bean のデフォルト名: "jsfNavigationHandler"。 |
| コンストラクターと説明 |
|---|
DelegatingNavigationHandlerProxy() 新しい DelegatingNavigationHandlerProxy を作成します。 |
DelegatingNavigationHandlerProxy(NavigationHandlerEE originalNavigationHandler) 新しい DelegatingNavigationHandlerProxy を作成します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected BeanFactory | getBeanFactory(FacesContextEE facesContext)Bean 名前解決を委譲する Spring BeanFactory を取得します。 |
protected NavigationHandlerEE | getDelegate(FacesContextEE facesContext) 委譲先のターゲット NavigationHandler を返します。 |
protected StringSE | getTargetBeanName(FacesContextEE facesContext)BeanFactory 内のターゲット NavigationHandler Bean の名前を返します。 |
protected WebApplicationContext | getWebApplicationContext(FacesContextEE facesContext)Bean 名前解決を委譲する Web アプリケーションコンテキストを取得します。 |
void | handleNavigation(FacesContextEE facesContext, StringSE fromAction, StringSE outcome)Spring アプリケーションコンテキストでターゲット Bean に委譲することにより、指定されたパラメーターによって暗示されるナビゲーションリクエストを処理します。 |
handleNavigationEEcloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic DelegatingNavigationHandlerProxy()
public DelegatingNavigationHandlerProxy(NavigationHandlerEE originalNavigationHandler)
originalNavigationHandler - オリジナルの NavigationHandlerpublic void handleNavigation(FacesContextEE facesContext, StringSE fromAction, StringSE outcome)
ターゲット Bean は、JSF NavigationHandler クラスを継承する必要があります。Spring の DecoratingNavigationHandler を継承する場合、引数として元の NavigationHandler を使用したオーバーロードされた handleNavigation メソッドが使用されます。それ以外の場合は、標準の handleNavigation メソッドが呼び出されます。
NavigationHandlerEE の handleNavigationEE protected NavigationHandlerEE getDelegate(FacesContextEE facesContext)
デフォルトでは、すべての呼び出しに対して、Spring ルート WebApplicationContext から "jsfNavigationHandler" という名前の Bean が取得されます。
facesContext - 現在の JSF コンテキスト getTargetBeanName(javax.faces.context.FacesContext), getBeanFactory(javax.faces.context.FacesContext)protected StringSE getTargetBeanName(FacesContextEE facesContext)
facesContext - 現在の JSF コンテキスト protected BeanFactory getBeanFactory(FacesContextEE facesContext)
デフォルトの実装は getWebApplicationContext に委譲します。オーバーライドして、解決する任意の BeanFactory 参照を提供できます。通常、これは完全な Spring ApplicationContext になります。
facesContext - 現在の JSF コンテキスト null)getWebApplicationContext(javax.faces.context.FacesContext)protected WebApplicationContext getWebApplicationContext(FacesContextEE facesContext)
デフォルトの実装は FacesContextUtils に委譲します。
facesContext - 現在の JSF コンテキスト null)FacesContextUtils.getRequiredWebApplicationContext(javax.faces.context.FacesContext)