|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectorg.apache.struts.action.ActionForm
ActionFormは、
1つ以上のActionMappingに任意に関連づけることのできるJavaBeanです。
このBeanのプロパティは、対応するAction.executeメソッドが呼び出される前に、
対応するリクエストパラメータで初期化されます。
An ActionForm is a JavaBean optionally associated with
one or more ActionMappings. Such a bean will have had its
properties initialized from the corresponding request parameters before
the corresponding Action.execute method is called.
Beanのプロパティが設定された後、
Actionのexecuteメソッドが呼び出される前に、
このBeanのvalidateメソッドが呼び出されます。
これはユーザが送信したプロパティが正しくて妥当であるかを確かめる機会をBeanに与えます。
このメソッドで問題が見つかった場合、
問題をカプセル化したエラーメッセージオブジェクトを返し、
コントローラサーブレットは対応する入力フォームに制御を戻します。
また、全てのプロパティが条件に合っていて、
対応するAction.executeメソッドが呼び出されるべきである場合は、
validateメソッドはnullを返します。
When the properties of this bean have been populated, but before the
execute method of the Action is called, this bean's
validate method will be called, which gives the bean a chance
to verify that the properties submitted by the user are correct and valid.
If this method finds problems, it returns an error messages object that
encapsulates those problems, and the controller servlet will return control
to the corresponding input form. Otherwise, the validate
method returns null, indicating that everything is acceptable
and the corresponding Action.execute method should be
called.
このクラスをインスタンス化するためにサブクラスを作成する必要があります。 サブクラスは公開したい全てのBeanプロパティでgetterメソッドとsetter メソッドを提供し、 さらににpublicメソッドやprotectedメソッドを機能の変更に応じてオーバライドすべきです。
This class must be subclassed in order to be instantiated. Subclasses should provide property getter and setter methods for all of the bean properties they wish to expose, plus override any of the public or protected methods for which they wish to provide modified functionality.
ActionFormはJavaBeanですので、
サブクラスもJavaBean仕様を満たすようにSerializableを実装すべきです。
コンテナによっては、
ActionFormが依存しているイントロスペクションAPIを用いるために、
オブジェクトがJavaBeanの全ての要件を満たすことが要求されます。
Because ActionForms are JavaBeans, subclasses should also implement
Serializable, as required by the JavaBean specification.
Some containers require that an object meet all JavaBean requirements
in order to use the introspection API upon which ActionForms rely.
| フィールドの概要 | |
protected MultipartRequestHandler |
multipartRequestHandler
このフォームのMultipartRequestHandler。 |
protected ActionServlet |
servlet
関連づけられているサーブレットのインスタンス。 |
| コンストラクタの概要 | |
ActionForm()
|
|
| メソッドの概要 | |
MultipartRequestHandler |
getMultipartRequestHandler()
このフォームの MultipartRequestHandlerを返します。
|
protected ActionServlet |
getServlet()
関連づけられているサーブレットのインスタンスを返します。 |
ActionServletWrapper |
getServletWrapper()
関連づけられているサーブレットのインスタンスを ActionServletWrapperとして返します。 |
void |
reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
Beanの全てのプロパティを必要に応じてデフォルトの状態にリセットします。 |
void |
reset(ActionMapping mapping,
javax.servlet.ServletRequest request)
Beanの全てのプロパティをデフォルトの状態にリセットします。 |
void |
setMultipartRequestHandler(MultipartRequestHandler multipartRequestHandler)
ファイルアップロードの処理に使うために提供されるHandlerを設定します。 |
void |
setServlet(ActionServlet servlet)
( servletがnullでない場合は)
関連づけられているサーブレットのインスタンスをセットします。
|
ActionErrors |
validate(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
HTTPリクエストにセットされているプロパティの妥当性を検証して、 見つかった全ての検証エラーをカプセル化した ActionErrorsオブジェクトを返します。
|
ActionErrors |
validate(ActionMapping mapping,
javax.servlet.ServletRequest request)
非HTTPリクエストにセットされているプロパティの妥当性を検証して、 見つかった全ての検証エラーをカプセル化した ActionErrorsオブジェクトを返します。
|
| クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| フィールドの詳細 |
protected transient ActionServlet servlet
関連づけられているサーブレットのインスタンス。
The servlet instance to which we are attached.
protected transient MultipartRequestHandler multipartRequestHandler
このフォームのMultipartRequestHandler。
nullのこともあります。
The MultipartRequestHandler for this form, can be
null.
| コンストラクタの詳細 |
public ActionForm()
| メソッドの詳細 |
protected ActionServlet getServlet()
関連づけられているサーブレットのインスタンスを返します。
Return the servlet instance to which we are attached.
public ActionServletWrapper getServletWrapper()
関連づけられているサーブレットのインスタンスをActionServletWrapperとして返します。
Return the controller servlet instance to which we are attached.
as an ActionServletWrapper.
ActionServletWrapperpublic MultipartRequestHandler getMultipartRequestHandler()
このフォームのMultipartRequestHandlerを返します。
この背景にある理由は、
MultipartRequestHandlerのfinishメソッドとrollback
メソッドのどちらか、または両方を使用することによって、
フォームBeanの開発者がマルチパートのリクエストのライフサイクルを操作できるようにするためです。
このフォームのenctypeが"multipart/form-data"でない場合はこのメソッドはnullを返します。
Return the MultipartRequestHandler for this form
The reasoning behind this is to give form bean developers
control over the lifecycle of their multipart requests
through the use of the finish and/or rollback
methods of MultipartRequestHandler. This method will return
null if this form's enctype is not
"multipart/request-data".
MultipartRequestHandlerpublic 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 void setMultipartRequestHandler(MultipartRequestHandler multipartRequestHandler)
ファイルアップロードの処理に使うために提供されるHandlerを設定します。
Set the Handler provides to use in dealing with file uploads.
multipartRequestHandler - ファイルアップロードに使用するHandler
public void reset(ActionMapping mapping,
javax.servlet.ServletRequest request)
Beanの全てのプロパティをデフォルトの状態にリセットします。 このメソッドはコントローラがプロパティを再設定する前に呼び出されます。
Reset all bean properties to their default state. This method is called before the properties are repopulated by the controller.
デフォルトの実装はこのメソッドのHTTPバージョンにフォワードします。
The default implementation attempts to forward to the HTTP version of this method.
mapping - このインスタンスを選択するために用いられたマッピング
request - 処理中のサーブレットリクエスト
public void reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
Beanの全てのプロパティを必要に応じてデフォルトの状態にリセットします。 このメソッドはコントローラがプロパティを再設定する前に呼び出されます。
Reset bean properties to their default state, as needed. This method is called before the properties are repopulated by the controller.
デフォルトの実装は何もしません。 実際に使う場合、 リセットが必要なプロパティはセッションスコープのフォームにあるチェックボックスだけです。 別の方法として、プロパティはフィールドの宣言時に初期値を設定できます。
The default implementation does nothing. In practice, the only properties that need to be reset are those which represent checkboxes on a session-scoped form. Otherwise, properties can be given initial values where the field is declared.
もし複数のリクエストにわたって値を集められるように(「ウィザード」形式) フォームをセッションスコープに格納する場合、プロパティをリセットするのなら、 どのプロパティをリセットするかに十分に注意しなければいけません。 上述の通り、セッションスコープのチェックボックスは、 プロパティを設定するどのページでもfalseにリセットしなければなりません。 これは、チェックボックスがクリアされた(false)時には値を送信しないためです。 セッションスコープのチェックボックスは、事前にリセットしない限り falseに設定されることはありません。
If the form is stored in session-scope so that values can be collected over multiple requests (a "wizard"), you must be very careful of which properties, if any, are reset. As mentioned, session-scope checkboxes must be reset to false for any page where this property is set. This is because the client does not submit a checkbox value when it is clear (false). If a session-scoped checkbox is not proactively reset, it can never be set to false.
「更新」タイプのページに関しては、 フォームの値を初期化する場所として、このメソッドはふさわしくありません (値の初期化はセットアップ用のActionの中で行なうべきです)。 たいていの場合にチェックボックスの値がfalseに設定されているかを気にする必要はありますが、 ほとんどの場合はこのメソッドを実装しないでおいて構いません。
This method is not the appropriate place to initialize form value for an "update" type page (this should be done in a setup Action). You mainly need to worry about setting checkbox values to false; most of the time you can leave this method unimplemented.
mapping - このインスタンスを選択するために用いられたマッピング
request - 処理中のサーブレットリクエスト
public ActionErrors validate(ActionMapping mapping,
javax.servlet.ServletRequest request)
非HTTPリクエストにセットされているプロパティの妥当性を検証して、
見つかった全ての検証エラーをカプセル化したActionErrorsオブジェクトを返します。
エラーが見つからなかった場合、
nullもしくは、
エラーメッセージが何も記録されていないActionErrorsオブジェクトを返します。
Validate the properties that have been set for this non-HTTP request,
and return an ActionErrors object that encapsulates any
validation errors that have been found. If no errors are found, return
null or an ActionErrors object with no
recorded error messages.
デフォルトの実装はこのメソッドのHTTPバージョンにフォワードします。
The default implementation attempts to forward to the HTTP version of this method.
mapping - このインスタンスを選択するために用いられたマッピング
request - 処理しているサーブレットリクエスト
public ActionErrors validate(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
HTTPリクエストにセットされているプロパティの妥当性を検証して、
見つかった全ての検証エラーをカプセル化したActionErrorsオブジェクトを返します。
エラーが見つからなかった場合、
nullもしくは、
エラーメッセージが何も記録されていないActionErrorsオブジェクトを返します。
Validate the properties that have been set for this HTTP request,
and return an ActionErrors object that encapsulates any
validation errors that have been found. If no errors are found,
return null or an ActionErrors object with
no recorded error messages.
デフォルトの実装は何の検証も行なわずにnullを返します。
サブクラスは独自の妥当性の検証を行なうためにこのメソッドをオーバライドしなくてはいけません。
The default implementation performs no validation and returns
null. Subclasses must override this method to provide
any validation they wish to perform.
mapping - このインスタンスを選択するために用いられたマッピング
request - 処理しているサーブレットリクエスト
DynaActionForm
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||