org.apache.struts.actions
クラス DispatchAction

java.lang.Object
  拡張org.apache.struts.action.Action
      拡張org.apache.struts.actions.DispatchAction
直系の既知のサブクラス:
LookupDispatchAction

public abstract class DispatchAction
extends Action

対応する ActionMapping の parameter プロパティに設定されたされた名前のリクエストパラメータに対応するパブリックメソッドへ処理を割り振る機能を持つ抽象 Action です。 この Action は、アプリケーションの設計を単純化するために、いくつものの類似したアクションを単一の Action クラスに結合したい場合に有用です。

An abstract Action that dispatches to a public method that is named by the request parameter whose name is specified by the parameter property of the corresponding ActionMapping. This Action is useful for developers who prefer to combine many similar actions into a single Action class, in order to simplify their application design.

このアクションを使用する場合には、以下のようなエントリを struts-config.xml ファイルに記述します:

To configure the use of this action in your struts-config.xml file, create an entry like this:

<action path="/saveSubscription" type="org.apache.struts.actions.DispatchAction" name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="method"/>

このエントリでは "method" という名前のリクエストパラメータの値を該当する"実行"メソッド(通常の Action.execute メソッドと同様の引数と返り値を持つメソッド)を選択するために使用します。 例えば以下のような3つのメソッドを同一のアクション内に持つことができます:

which will use the value of the request parameter named "method" to pick the appropriate "execute" method, which must have the same signature (other than method name) of the standard Action.execute method. For example, you might have the following three methods in the same action:

また、以下のような URL でこの中の1つのメソッドを呼び出すことができます。

and call one of the methods with a URL like this:

http://localhost:8080/myapp/saveSubscription.do?method=update

- 呼び出されるメソッド以外のこのアクションに設定された属性は共有されます。 これはひとつの DispatchAction サブクラスに容易にまとめることのできる処理に関してある種の制約となります。

NOTE - All of the other mapping characteristics of this action must be shared by the various handlers. This places some constraints over what types of handlers may reasonably be packaged into the same DispatchAction subclass.

バージョン:
$Revision: 1.5 $ $Date: 2003/12/17 09:52:06 $
作成者:
Niall Pemberton , Craig R. McClanahan, Ted Husted
翻訳者:
高橋 一隆, 日置 聡
校正者:
未定
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/12/16

フィールドの概要
protected  java.lang.Class clazz
          この DispatchAction クラスの Class インスタンス。
protected static org.apache.commons.logging.Log log
          Commons Logging インスタンス。
protected static MessageResources messages
          このパッケージのメッセージリソース。
protected  java.util.HashMap methods
          メソッド名をキーとした、このクラス自身の処理を呼ぶための Method オブジェクトのセット。
protected  java.lang.Class[] types
          リフレクションにてメソッドを検索する際に使用される引数の型のセット。
 
クラス org.apache.struts.action.Action から継承したフィールド
ACTION_SERVLET_KEY, APPLICATION_KEY, DATA_SOURCE_KEY, defaultLocale, ERROR_KEY, EXCEPTION_KEY, FORM_BEANS_KEY, FORWARDS_KEY, LOCALE_KEY, MAPPING_KEY, MAPPINGS_KEY, MESSAGE_KEY, MESSAGES_KEY, MULTIPART_KEY, PLUG_INS_KEY, REQUEST_PROCESSOR_KEY, servlet, SERVLET_KEY, TRANSACTION_TOKEN_KEY
 
コンストラクタの概要
DispatchAction()
           
 
メソッドの概要
protected  ActionForward dispatchMethod(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String name)
          指定されたメソッドに処理を割り振ります。
 ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          指定されたHTTP リクエストを処理し、対応する HTTP レスポンスを返します(または HTTP レスポンスを生成する他の Web コンポーネントに対して転送を行います)。
protected  java.lang.reflect.Method getMethod(java.lang.String name)
          指定された名前を持つ、execute メソッドと同じ引数、返り値をもつこのクラス内のメソッドを取得します。
protected  ActionForward unspecified(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          指定されたリクエストパラメータの値が設定されていなかった場合に呼ばれるメソッドです。
 
クラス org.apache.struts.action.Action から継承したメソッド
execute, generateToken, getDataSource, getDataSource, getLocale, getResources, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, perform, perform, resetToken, saveErrors, saveMessages, saveToken, setLocale, setServlet, toHex
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

clazz

protected java.lang.Class clazz
この DispatchAction クラスの Class インスタンス。
The Class instance of this DispatchAction class.


log

protected static org.apache.commons.logging.Log log
Commons Logging インスタンス。
Commons Logging instance.


messages

protected static MessageResources messages
このパッケージのメッセージリソース。
The message resources for this package.


methods

protected java.util.HashMap methods
メソッド名をキーとした、このクラス自身の処理を呼ぶための Method オブジェクトのセット。 このコレクションは異なるメソッドが呼ばれる際に生成されるため、Method オブジェクトの生成はメソッド名毎に1度だけ行われます。
The set of Method objects we have introspected for this class, keyed by method name. This collection is populated as different methods are called, so that introspection needs to occur only once per method name.


types

protected java.lang.Class[] types
リフレクションにてメソッドを検索する際に使用される引数の型のセット。 このメンバがメソッドの検索の際には常に使用されるため、引数の型の処理は1回ですみます。
The set of argument type classes for the reflected method call. These are the same for all calls, so calculate them only once.

コンストラクタの詳細

DispatchAction

public DispatchAction()
メソッドの詳細

execute

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.lang.Exception
指定されたHTTP リクエストを処理し、対応する HTTP レスポンスを返します(または HTTP レスポンスを生成する他の Web コンポーネントに対して転送を行います)。 処理をどこにどうやって転送すべきかが記述された ActionForward インスタンスまたは、レスポンスが既に完了している場合には null を返します。
Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it). Return an ActionForward instance describing where and how control should be forwarded, or null if the response has already been completed.

オーバーライド:
クラス Action 内の execute
パラメータ:
mapping - このインスタンスを選択する際に使用された ActionMapping
The ActionMapping used to select this instance
form - このリクエストに対応する ActionForm(もしあれば)
The optional ActionForm bean for this request (if any)
request - 処理中のHTTPリクエスト
The HTTP request we are processing
response - 生成中のHTTPレスポンス
The HTTP response we are creating
例外:
java.lang.Exception - 例外が発生した場合
if an exception occurs

unspecified

protected ActionForward unspecified(ActionMapping mapping,
                                    ActionForm form,
                                    javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
                             throws java.lang.Exception
指定されたリクエストパラメータの値が設定されていなかった場合に呼ばれるメソッドです。 DispatchAction のサブクラスで HTTP の"不正なリクエスト"エラー以外の振る舞いをさせたい場合にはこのメソッドをオーバライドしてください。
Method which is dispatched to when there is no value for specified request parameter included in the request. Subclasses of DispatchAction should override this method if they wish to provide default behavior different than producing an HTTP "Bad Request" error.

例外:
java.lang.Exception

dispatchMethod

protected ActionForward dispatchMethod(ActionMapping mapping,
                                       ActionForm form,
                                       javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       java.lang.String name)
                                throws java.lang.Exception
指定されたメソッドに処理を割り振ります。
Dispatch to the specified method.

例外:
java.lang.Exception
導入されたバージョン:
Struts 1.1

getMethod

protected java.lang.reflect.Method getMethod(java.lang.String name)
                                      throws java.lang.NoSuchMethodException
指定された名前を持つ、execute メソッドと同じ引数、返り値をもつこのクラス内のメソッドを取得します。
Introspect the current class to identify a method of the specified name that accepts the same parameter types as the execute method does.

パラメータ:
name - このクラス内のメソッド名
Name of the method to be introspected
例外:
java.lang.NoSuchMethodException - 指定されたメソッドが存在しない場合
if no such method can be found


このドキュメントは、Ja-Jakartaにより訳されました。コメントがある場合は、report@jajakarta.orgまでお願いします。
Copyright (C) 2000-2003 - Apache Software Foundation