org.apache.struts.actions
クラス MappingDispatchAction

java.lang.Object
  拡張org.apache.struts.action.Action
      拡張org.apache.struts.actions.DispatchAction
          拡張org.apache.struts.actions.MappingDispatchAction

public class MappingDispatchAction
extends DispatchAction

対応するActionMappingのparameter属性により指名された、 パブリックメソッドへ振り分ける抽象Actionです。 一つのActionクラスに複数の関係付けられたアクションをまとめるため、 開発者にとってこれは有効です。

An abstract Action that dispatches to a public method that is named by the parameter attribute of the corresponding ActionMapping. This is useful for developers who prefer to combine many related actions into a single Action class.

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.example.SubscriptionAction"
           name="subscriptionForm"
          scope="request"
          input="/subscription.jsp"
      parameter="method"/>
 

ここで'method'は、 通常のAction.executeメソッドと同様の引数と返り値を持つ、 MappingDispatchActionのサブクラス中のメソッドの名前です。 (Action.executeとはメソッド名が異なります。) 例えば、 以下の様な複数メソッドを使うため、 一つのMappingDispatchActionクラス中に記述し運用するためメソッドをまとめます。

where 'method' is the name of a method in your subclass of MappingDispatchAction that has the same signature (other than method name) of the standard Action.execute method. For example, you might combine the methods for managing a subscription into a single MappingDispatchAction class using the following methods:

このクラスを参照する<アクション>の設定に一致したメソッドを生成します。

for which you would create corresponding <action> configurations that reference this class:


  <action path="/createSubscription" 
          type="org.example.SubscriptionAction"
          parameter="create">
      <forward name="success" path="/editSubscription.jsp"/>
  </action>
 
  <action path="/editSubscription" 
          type="org.example.SubscriptionAction"
          parameter="edit">
      <forward name="success" path="/editSubscription.jsp"/>
  </action>

  <action path="/saveSubscription" 
          type="org.example.SubscriptionAction" 
          parameter="save"
          name="subscriptionForm" 
          validate="true" 
          input="/editSubscription.jsp" 
          scope="request">
      <forward name="success" path="/savedSubscription.jsp"/>
  </action>

  <action path="/deleteSubscription" 
          type="org.example.SubscriptionAction"
          name="subscriptionForm"
          scope="request"
          input="/subscription.jsp"
          parameter="delete">
      <forward name="success" path="/deletedSubscription.jsp"/>
  </action>

  <action path="/listSubscriptions" 
          type="org.example.SubscriptionAction"
          parameter="list">
      <forward name="success" path="/subscriptionList.jsp"/>
  </action>
 

注意 - DispatchActionとは異なり、 マッピング特性がさまざまな扱いの間で異なることが可能なため、 例えば使用するフォームまたはバリデーションが違っても、 同じクラスにアクションをまとめることができるのです。 また、 アプリケーションのユーザが見ることができる様なリクエスト変数は、 扱うメソッドの選択を可能とするために要求されません。

NOTE - Unlike DispatchAction, mapping characteristics may differ between the various handlers, so you can combine actions in the same class that, for example, differ in their use of forms or validation. Also, a request parameter, which would be visible to the application user, is not required to enable selection of the handler method.

導入されたバージョン:
Struts 1.2
バージョン:
$Revision: 1.6 $ $Date: 2005/05/09 13:25:28 $
翻訳者:
棚澤 昌幸
校正者:
翻訳状況:
初稿(校正者募集中)

フィールドの概要
private static org.apache.commons.logging.Log log
          Commons Loggingインスタンス。
 
クラス org.apache.struts.actions.DispatchAction から継承したフィールド
clazz, messages, methods, types
 
クラス org.apache.struts.action.Action から継承したフィールド
defaultLocale, servlet
 
コンストラクタの概要
MappingDispatchAction()
           
 
メソッドの概要
 ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          指定されたHTTPリクエストを処理し、 対応するHTTPレスポンスを生成します。
protected  java.lang.String getMethodName(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String parameter)
          パラメータ値で与えられた、メソッド名を返します。
protected  ActionForward unspecified(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          ActionMappingでパラメータのための値が無い時に振り分けられるメソッドです。
 
クラス org.apache.struts.actions.DispatchAction から継承したメソッド
cancelled, dispatchMethod, getMethod
 
クラス org.apache.struts.action.Action から継承したメソッド
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

log

private static org.apache.commons.logging.Log log

Commons Loggingインスタンス。

Commons Logging instance.

コンストラクタの詳細

MappingDispatchAction

public MappingDispatchAction()
メソッドの詳細

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.

このメソッドは、 ActionMappingの'parameter'属性とJavaのイントロスペクションを使い、 MappingDispatchActionの他のメソッドへリクエストを振り分けます。

This method dispatches the request to other methods of MappingDispatchAction using the 'parameter' attribute of ActionMapping and Java Introspection.

オーバーライド:
クラス DispatchAction 内の execute
パラメータ:
mapping - このインスタンスを選択するため使われたActionMapping
@param mapping The ActionMapping used to select this instance
form - (もしあれば)このリクエストに対応するActionForm Bean
@param form The optional ActionForm bean for this request (if any)
request - 処理中のHTTPリクエスト
@param request The HTTP request we are processing
response - 生成するHTTPレスポンス
@param response The HTTP response we are creating
戻り値:
どこにそしてどのようにフォワードすべきかを記述したActionForwardインスタンスまたは、 レスポンスが既に完成されている場合はnull
@return Return an ActionForward instance describing where and how control should be forwarded, or null if the response has already been completed.
例外:
java.lang.Exception - 例外が発生した場合
@exception 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

ActionMappingでパラメータのための値が無い時に振り分けられるメソッドです。 ServletExceptionをスローするのではなくデフォルト挙動を提供することを望む場合、 MappingDispatchActionのサブクラスはこのメソッドをオーバライドすべきです。

Method which is dispatched to when there is no value for the parameter in the ActionMapping. Subclasses of MappingDispatchAction should override this method if they wish to provide default behavior different than throwing a ServletException.

オーバーライド:
クラス DispatchAction 内の unspecified
パラメータ:
mapping - このインスタンスを選択するため使われたActionMapping
@param mapping The ActionMapping used to select this instance
form - (もしあれば)このリクエストに対応するActionForm Bean
@param form The optional ActionForm bean for this request (if any)
request - 処理中のHTTPリクエスト
@param request The HTTP request we are processing
response - 生成するHTTPレスポンス
@param response The HTTP response we are creating
戻り値:
どこにそしてどのようにフォワードすべきかを記述したActionForwardインスタンスまたは、 レスポンスが既に完成されている場合はnull
@return Return an ActionForward instance describing where and how control should be forwarded, or null if the response has already been completed.
例外:
java.lang.Exception - 例外が発生した場合
@exception Exception if an exception occurs

getMethodName

protected java.lang.String getMethodName(ActionMapping mapping,
                                         ActionForm form,
                                         javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         java.lang.String parameter)
                                  throws java.lang.Exception

パラメータ値で与えられた、メソッド名を返します。

Returns the method name, given a parameter's value.

オーバーライド:
クラス DispatchAction 内の getMethodName
パラメータ:
mapping - このインスタンスを選択するため使われたActionMapping
@param mapping The ActionMapping used to select this instance
form - (もしあれば)このリクエストに対応するActionForm Bean
@param form The optional ActionForm bean for this request (if any)
request - 処理中のHTTPリクエスト
@param request The HTTP request we are processing
response - 生成するHTTPレスポンス
@param response The HTTP response we are creating
parameter - ActionMappingのパラメータ名
@param parameter The ActionMapping parameter's name
戻り値:
メソッド名
@return The method's name.
例外:
java.lang.Exception
導入されたバージョン:
Struts 1.2.0


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