|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectorg.apache.struts.action.Action
org.apache.struts.actions.DispatchAction
org.apache.struts.actions.MappingDispatchAction
対応する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.
| フィールドの概要 | |
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 |
| フィールドの詳細 |
private static org.apache.commons.logging.Log log
Commons Loggingインスタンス。
| コンストラクタの詳細 |
public MappingDispatchAction()
| メソッドの詳細 |
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を返します。
ActionForward instance describing where and how
control should be forwarded, or null if the response has
already been completed.このメソッドは、
ActionMappingの'parameter'属性とJavaのイントロスペクションを使い、
MappingDispatchActionの他のメソッドへリクエストを振り分けます。
MappingDispatchAction using the 'parameter' attribute of
ActionMapping and Java Introspection.
DispatchAction 内の executemapping - このインスタンスを選択するため使われたActionMapping
form - (もしあれば)このリクエストに対応するActionForm Bean
request - 処理中のHTTPリクエスト
response - 生成するHTTPレスポンス
ActionForwardインスタンスまたは、
レスポンスが既に完成されている場合はnull
ActionForward instance describing where
and how control should be forwarded, or null if
the response has already been completed.java.lang.Exception - 例外が発生した場合
protected ActionForward unspecified(ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
ActionMappingでパラメータのための値が無い時に振り分けられるメソッドです。
ServletExceptionをスローするのではなくデフォルト挙動を提供することを望む場合、
MappingDispatchActionのサブクラスはこのメソッドをオーバライドすべきです。
MappingDispatchAction should override this method
if they wish to provide default behavior different than throwing a
ServletException.
DispatchAction 内の unspecifiedmapping - このインスタンスを選択するため使われたActionMapping
form - (もしあれば)このリクエストに対応するActionForm Bean
request - 処理中のHTTPリクエスト
response - 生成するHTTPレスポンス
ActionForwardインスタンスまたは、
レスポンスが既に完成されている場合はnull
ActionForward instance describing where
and how control should be forwarded, or null if
the response has already been completed.java.lang.Exception - 例外が発生した場合
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
パラメータ値で与えられた、メソッド名を返します。
DispatchAction 内の getMethodNamemapping - このインスタンスを選択するため使われたActionMapping
form - (もしあれば)このリクエストに対応するActionForm Bean
request - 処理中のHTTPリクエスト
response - 生成するHTTPレスポンス
parameter - ActionMappingのパラメータ名
ActionMapping parameter's namejava.lang.Exception
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||