|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectorg.apache.struts.action.Action
Actionは、受信した
HTTPリクエストの内容とそのリクエストを処理するために実行されるべきビジネスロジックを適合させます。
コントローラ(RequestProcessor)は、
それぞれのリクエストに適切なActionを選択して(必要に応じて)インスタンスを生成し、
executeメソッドを呼び出します。
An Action is an adapter between the contents of an incoming
HTTP request and the corresponding business logic that should be executed to
process this request. The controller (RequestProcessor) will select an
appropriate Action for each request, create an instance (if necessary),
and call the execute method.
コントローラは同時に要求された複数のリクエストに対して同一のインスタンスを共有するため、 Actionはスレッドセーフとなるようにプログラムしなくてはいけません。 すなわち、次の項目に注意して設計すべきです。
Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests. This means you should design with the following items in mind:
Actionインスタンスが最初に生成される時、
コントローラはそのActionが関連付けられたサーブレットインスタンスを識別するため、
nullでない引数でsetServletメソッドを呼び出します
サーブレットをシャットダウン(または再起動)する時、
Actionに割り当てられている使用中のリソースをすべてクリーンアップするため、
nullを引数にsetServletメソッドを呼び出します。
When an Action instance is first created, the controller
will call setServlet with a non-null argument to
identify the servlet instance to which this Action is attached.
When the servlet is to be shut down (or restarted), the
setServlet method will be called with a null
argument, which can be used to clean up any allocated resources in use
by this Action.
| フィールドの概要 | |
protected static java.util.Locale |
defaultLocale
推奨されていません。 Locale.getDefaultを直接使ってください。 Struts 1.2.より後で削除されます。 @deprecated Use Locale.getDefault directly. This will be removed after
Struts 1.2. |
protected ActionServlet |
servlet
関連付けられたサーブレット。 |
private static TokenProcessor |
token
トークン機能で使用される TokenProcessorのインスタンス。 |
| コンストラクタの概要 | |
Action()
|
|
| メソッドの概要 | |
protected void |
addErrors(javax.servlet.http.HttpServletRequest request,
ActionMessages errors)
メッセージが必要な場合は、 <html:messages>タグが使用できるように適切なリクエスト属性に指定されたエラーキーを追加します。 |
protected void |
addMessages(javax.servlet.http.HttpServletRequest request,
ActionMessages messages)
(messages="true"が設定され)メッセージが必要な場合は、 <html:messages>タグで使用できるように適切なリクエスト属性に指定されたメッセージキーを追加します。 |
ActionForward |
execute(ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
指定されたHTTPリクエストを処理して、 対応するHTTPレスポンスを生成します。 |
ActionForward |
execute(ActionMapping mapping,
ActionForm form,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
指定された非HTTPリクエストを処理して、 対応する非HTTPレスポンスを生成します。 |
protected java.lang.String |
generateToken(javax.servlet.http.HttpServletRequest request)
各トランザクションに対してリクエストを1回だけにするために使用する、 新しいトランザクショントークンを生成します。 |
protected javax.sql.DataSource |
getDataSource(javax.servlet.http.HttpServletRequest request)
現在のモジュールのデフォルトのデータソースを返します。 |
protected javax.sql.DataSource |
getDataSource(javax.servlet.http.HttpServletRequest request,
java.lang.String key)
現在のモジュールの指定されたデータソースを返します。 |
protected ActionMessages |
getErrors(javax.servlet.http.HttpServletRequest request)
直前のアクションでリクエストに置かれた既存のエラーを全て取り出します。 |
protected java.util.Locale |
getLocale(javax.servlet.http.HttpServletRequest request)
ユーザが現在選択しているLocaleを返します。 |
protected ActionMessages |
getMessages(javax.servlet.http.HttpServletRequest request)
直前のアクションでリクエストに置かれた既存のメッセージを全て取り出します。 |
protected MessageResources |
getResources(javax.servlet.http.HttpServletRequest request)
現在のモジュールのデフォルトのメッセージリソースを返します。 |
protected MessageResources |
getResources(javax.servlet.http.HttpServletRequest request,
java.lang.String key)
現在のモジュールの指定されたメッセージリソースを返します。 |
ActionServlet |
getServlet()
関連付けられたサーブレットのインスタンスを返します。 |
protected boolean |
isCancelled(javax.servlet.http.HttpServletRequest request)
現在のフォームのキャンセルボタンが押された場合に trueを返します。
|
protected boolean |
isTokenValid(javax.servlet.http.HttpServletRequest request)
ユーザの現在のセッションにトランザクショントークンが保持され、 かつ、このアクションのリクエストパラメータとして送信された値がそのトークンとマッチする場合は、 trueを返します。
|
protected boolean |
isTokenValid(javax.servlet.http.HttpServletRequest request,
boolean reset)
ユーザの現在のセッションにトランザクショントークンが保持され、 かつ、このアクションのリクエストパラメータとして送信された値がそのトークンとマッチする場合は trueを返します。
|
protected void |
resetToken(javax.servlet.http.HttpServletRequest request)
ユーザのセッションに保持されているトランザクショントークンをリセットします。 |
protected void |
saveErrors(javax.servlet.http.HttpServletRequest request,
ActionErrors errors)
推奨されていません。 代わりにsaveErrors(HttpServletRequest, ActionMessages)を使用して下さい。 このメソッドはStruts 1.2.より後で削除されます。 @deprecated Use saveErrors(HttpServletRequest, ActionMessages) instead.
This will be removed after Struts 1.2. |
protected void |
saveErrors(javax.servlet.http.HttpServletRequest request,
ActionMessages errors)
何らかのメッセージが必要な場合、 <html:errors>タグが利用できるように、 適切なリクエスト属性に指定されたエラーメッセージキーを保存します。 |
protected void |
saveMessages(javax.servlet.http.HttpServletRequest request,
ActionMessages messages)
(messages="true"が設定され)メッセージが必要な場合、 <html:messages>タグが使用できるように、 適切なリクエスト属性の中に指定されたメッセージキーを保存します。 |
protected void |
saveMessages(javax.servlet.http.HttpSession session,
ActionMessages messages)
(messages="true"が設定され)メッセージが必要な場合、 <html:messages>タグが使用できるように、 適切なリクエスト属性の中に指定されたメッセージキーを保存します。 |
protected void |
saveToken(javax.servlet.http.HttpServletRequest request)
必要に応じて新たなセッションを生成し、 ユーザの現在のセッションに新しいトランザクショントークンを保存します。 |
protected void |
setLocale(javax.servlet.http.HttpServletRequest request,
java.util.Locale locale)
HttpSessionにユーザが現在選択したLocaleを設定します。 |
void |
setServlet(ActionServlet servlet)
( servletがnullでない場合)関連付けられたサーブレットのインスタンスを設定します。
|
| クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| フィールドの詳細 |
private static TokenProcessor token
トークン機能で使用されるTokenProcessorのインスタンス。
An instance of TokenProcessor to use for token functionality.
protected static java.util.Locale defaultLocale
システムのデフォルトLocale。
The system default Locale.
protected ActionServlet servlet
関連付けられたサーブレット。
The servlet to which we are attached.
| コンストラクタの詳細 |
public Action()
| メソッドの詳細 |
public ActionServlet getServlet()
関連付けられたサーブレットのインスタンスを返します。
Return the servlet instance to which we are attached.
public void setServlet(ActionServlet servlet)
(servletがnullでない場合)関連付けられたサーブレットのインスタンスを設定します。
(servletがnullの場合)関連付けられたサーブレットのインスタンスを解放します。
Set the servlet instance to which we are attached (if
servlet is non-null), or release any allocated resources
(if servlet is null).
servlet - もしあれば、新しいコントローラサーブレット
public ActionForward execute(ActionMapping mapping,
ActionForm form,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
throws java.lang.Exception
指定された非HTTPリクエストを処理して、
対応する非HTTPレスポンスを生成します。
(またはレスポンスを生成する他のWebコンポーネントにリクエストをフォワードします。)
併せてビジネスロジックがスローする例外のハンドリングも提供します。
コントロールをどこに/どうやってフォワードすべきかが記述されたActionForwardインスタンスもしくは、
レスポンスが既に完了している場合はnullを返します。
Process the specified non-HTTP request, and create the
corresponding non-HTTP response (or forward to another web
component that will create it), with provision for handling
exceptions thrown by the business logic.
Return an {@link ActionForward} instance describing where and how
control should be forwarded, or null if the response has
already been completed.
デフォルトの実装では、 このメソッドのHTTPバージョンにフォワードしようとします。
The default implementation attempts to forward to the HTTP version of this method.
mapping - このインスタンスを選択するために使用するActionMapping
form - このリクエストのためのActionForm Bean(もしあれば)
request - 処理中の非HTTPリクエスト
response - 生成する非HTTPレスポンス
java.lang.Exception - アプリケーションのビジネスロジックが例外をスローした場合
public ActionForward execute(ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
指定された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),
with provision for handling exceptions thrown by the business logic.
Return an {@link ActionForward} instance describing where and how
control should be forwarded, or null if the response
has already been completed.
mapping - このインスタンスを選択するために使用するActionMapping
form - このリクエストのためのActionForm Bean(もしあれば)
request - 処理中のHTTPリクエスト
response - 生成するHTTPレスポンス
java.lang.Exception - アプリケーションのビジネスロジックが例外をスローした場合
protected void addMessages(javax.servlet.http.HttpServletRequest request,
ActionMessages messages)
(messages="true"が設定され)メッセージが必要な場合は、 <html:messages>タグで使用できるように適切なリクエスト属性に指定されたメッセージキーを追加します。 まだ属性が存在しない場合は、属性を初期化します。 それ以外の場合は、このリクエスト属性は設定されません。
request - 処理中のサーブレットリクエスト
messages - メッセージオブジェクト
protected void addErrors(javax.servlet.http.HttpServletRequest request,
ActionMessages errors)
メッセージが必要な場合は、 <html:messages>タグが使用できるように適切なリクエスト属性に指定されたエラーキーを追加します。 まだ属性が存在しない場合は、属性を初期化します。 それ以外の場合は、このリクエスト属性は設定されません。
request - 処理中のサーブレットリクエスト
errors - エラーオブジェクト
protected java.lang.String generateToken(javax.servlet.http.HttpServletRequest request)
各トランザクションに対してリクエストを1回だけにするために使用する、 新しいトランザクショントークンを生成します。
Generate a new transaction token, to be used for enforcing a single request for a particular transaction.
request - 処理中のリクエスト
protected javax.sql.DataSource getDataSource(javax.servlet.http.HttpServletRequest request)
現在のモジュールのデフォルトのデータソースを返します。
Return the default data source for the current module.
request - 処理中のサーブレットリクエスト
protected javax.sql.DataSource getDataSource(javax.servlet.http.HttpServletRequest request,
java.lang.String key)
現在のモジュールの指定されたデータソースを返します。
Return the specified data source for the current module.
request - 処理中のサーブレットリクエスト
key - <data-sources>要素内でデータソースを特定するためのキー
<message-resources>" は
"<data-sources>"が正しいと思われます(Bug#33876)が、
最新版ではこのメソッドそのものが削除されてしまいました。]<message-resources> element for the
requested bundleprotected ActionMessages getErrors(javax.servlet.http.HttpServletRequest request)
直前のアクションでリクエストに置かれた既存のエラーを全て取り出します。
Actionの開始時にnew ActionMessages()という形で生成する代わりに、
このメソッドを呼ぶことができます。
これにより、saveErrors()メソッドで全ての既存のエラーを消すのを防げます。
new ActionMessages() at the beginning of an Action
This will prevent saveErrors() from wiping out any existing Errors
request - 処理中のサーブレットリクエスト
protected java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
ユーザが現在選択しているLocaleを返します。
Return the user's currently selected Locale.
request - 処理中のリクエスト
protected ActionMessages getMessages(javax.servlet.http.HttpServletRequest request)
直前のアクションでリクエストに置かれた既存のメッセージを全て取り出します。
Actionの開始時にnew ActionMessages()という形で生成する代わりに、
このメソッドを呼ぶことができます。
これにより、saveMessages()メソッドで全ての既存のメッセージを消すことを防ぎます。
new ActionMessages() at the beginning of an Action
This will prevent saveMessages() from wiping out any existing Messages
request - 処理中のリクエスト
protected MessageResources getResources(javax.servlet.http.HttpServletRequest request)
現在のモジュールのデフォルトのメッセージリソースを返します。
Return the default message resources for the current module.
request - 処理中のサーブレットリクエスト
protected MessageResources getResources(javax.servlet.http.HttpServletRequest request,
java.lang.String key)
現在のモジュールの指定されたメッセージリソースを返します。
Return the specified message resources for the current module.
request - 処理中のサーブレットリクエスト
key - 要求されているメッセージのまとまりに対応する、
<message-resources>要素内でメッセージリソースを特定するためのキー
<message-resources> element for the
requested bundleprotected boolean isCancelled(javax.servlet.http.HttpServletRequest request)
現在のフォームのキャンセルボタンが押された場合にtrueを返します。
このメソッドは、
リクエスト属性Globals.CANCEL_KEYが設定されているかどうかをチェックします。
この属性が通常設定されるのは、
現在のリクエストにおいてCancelTagが生成したキャンセルボタンをユーザが押した時です。
trueの場合、
ActionFormのvalidate()メソッドによるバリデーションを、
コントローラサーブレットはスキップします。
Returns true if the current form's cancel button was
pressed. This method will check if the Globals.CANCEL_KEY
request attribute has been set, which normally occurs if the cancel
button generated by CancelTag was pressed by the user
in the current request. If true, validation performed
by an ActionForm's validate() method
will have been skipped by the controller servlet.
request - 処理中のサーブレットリクエスト
CancelTagprotected boolean isTokenValid(javax.servlet.http.HttpServletRequest request)
ユーザの現在のセッションにトランザクショントークンが保持され、
かつ、このアクションのリクエストパラメータとして送信された値がそのトークンとマッチする場合は、
trueを返します。
次のいずれかの場合はfalseを返します。
Return true if there is a transaction token stored in
the user's current session, and the value submitted as a request
parameter with this action matches it. Returns false
under any of the following circumstances:
request - 処理中のサーブレットリクエスト
protected boolean isTokenValid(javax.servlet.http.HttpServletRequest request,
boolean reset)
ユーザの現在のセッションにトランザクショントークンが保持され、
かつ、このアクションのリクエストパラメータとして送信された値がそのトークンとマッチする場合は
trueを返します。
次のいずれかの場合はfalseを返します。
false."は、
"Returns false under any of the following circumstances:"として訳しています。 Bug#33876]Return true if there is a transaction token stored in
the user's current session, and the value submitted as a request
parameter with this action matches it. Returns false.
request - 処理中のサーブレットリクエスト
reset - チェック後にトークンをリセットするか否か?
protected void resetToken(javax.servlet.http.HttpServletRequest request)
ユーザのセッションに保持されているトランザクショントークンをリセットします。 これは、 次に送信されるリクエストではトランザクショントークンをチェックする必要がないことを示します。
Reset the saved transaction token in the user's session. This indicates that transactional token checking will not be needed on the next request that is submitted.
request - 処理中のサーブレットリクエスト
protected void saveErrors(javax.servlet.http.HttpServletRequest request,
ActionErrors errors)
何らかのメッセージが必要な場合、 <html:errors>タグが利用できるように、 適切なリクエスト属性に指定されたエラーメッセージキーを保存します。 それ以外の場合、 リクエスト属性が生成されないようにします。
Save the specified error messages keys into the appropriate request attribute for use by the <html:errors> tag, if any messages are required. Otherwise, ensure that the request attribute is not created.
request - 処理中のサーブレットリクエスト
errors - エラーメッセージオブジェクト
protected void saveErrors(javax.servlet.http.HttpServletRequest request,
ActionMessages errors)
何らかのメッセージが必要な場合、 <html:errors>タグが利用できるように、 適切なリクエスト属性に指定されたエラーメッセージキーを保存します。 それ以外の場合、 リクエスト属性が生成されないようにします。
Save the specified error messages keys into the appropriate request attribute for use by the <html:errors> tag, if any messages are required. Otherwise, ensure that the request attribute is not created.
request - 処理中のサーブレットリクエスト
errors - エラーメッセージオブジェクト
protected void saveMessages(javax.servlet.http.HttpServletRequest request,
ActionMessages messages)
(messages="true"が設定され)メッセージが必要な場合、 <html:messages>タグが使用できるように、 適切なリクエスト属性の中に指定されたメッセージキーを保存します。 それ以外の場合、リクエスト属性は設定されません。
Save the specified messages keys into the appropriate request attribute for use by the <html:messages> tag (if messages="true" is set), if any messages are required. Otherwise, ensure that the request attribute is not created.
request - 処理中のサーブレットリクエスト
messages - 保存するメッセージ
nullまたは空のメッセージの場合、
リクエスト中に存在する全てのActionMessagesを削除します。
null or empty
messages removes any existing ActionMessages in the request.
protected void saveMessages(javax.servlet.http.HttpSession session,
ActionMessages messages)
(messages="true"が設定され)メッセージが必要な場合、 <html:messages>タグが使用できるように、 適切なリクエスト属性の中に指定されたメッセージキーを保存します。 それ以外の場合、セッション属性は生成されません。
Save the specified messages keys into the appropriate session attribute for use by the <html:messages> tag (if messages="true" is set), if any messages are required. Otherwise, ensure that the session attribute is not created.
session - メッセージを保存するセッション
messages - 保存するメッセージ
nullまたは空のメッセージの場合、
リクエスト中に存在する全てのActionMessagesを削除します。
null or empty
messages removes any existing ActionMessages in the session.protected void saveToken(javax.servlet.http.HttpServletRequest request)
必要に応じて新たなセッションを生成し、 ユーザの現在のセッションに新しいトランザクショントークンを保存します。
Save a new transaction token in the user's current session, creating a new session if necessary.
request - 処理中のサーブレットリクエスト
protected void setLocale(javax.servlet.http.HttpServletRequest request,
java.util.Locale locale)
HttpSessionにユーザが現在選択したLocaleを設定します。
Set the user's currently selected Locale into their
HttpSession.
request - 処理中のリクエスト
locale - 設定するユーザが選択したLocale、
またはサーバーのデフォルトLocaleを選択する場合はnull
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||