org.apache.struts.action
クラス ActionForm

java.lang.Object
  拡張org.apache.struts.action.ActionForm
すべての実装インタフェース:
java.io.Serializable
直系の既知のサブクラス:
DynaActionForm, ValidatorForm

public abstract class ActionForm
extends java.lang.Object
implements java.io.Serializable

ActionFormは1つ以上のActionMappings に関連づけることのできるJavaBeanです。 このBeanのプロパティは、対応するアクションの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 corresonding action's execute method is called.

Beanのプロパティが設定されると、 アクションのexecuteメソッドが呼び出される前にこのBeanの validateメソッドが呼び出されます。 これはユーザから提示されたプロパティが正しくて妥当であるかを確かめる機会を Beanに与えます。 このメソッドで問題が発見された場合、 発生した問題をカプセル化したエラーメッセージオブジェクトを返し、 コントローラServletは対応する入力フォームにコントロールを返します。 また、全てのプロパティが条件に合っていて、 対応するアクションの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's 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.

ActionFormsはJavaBeansですので、 JavaBean仕様を満たすようサブクラスも Serializableを実装すべきです。 いくつかのコンテナでは、 ActionFormsが頼みにしているイントロスペクション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.

バージョン:
$Revision: 1.4 $ $Date: 2003/12/16 16:46:16 $
作成者:
Craig R. McClanahan, Ted Husted
関連項目:
直列化された形式
翻訳者:
横田 健彦
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/12/15

フィールドの概要
protected  MultipartRequestHandler multipartRequestHandler
          このフォームのMultipartRequestHandlerです。
protected  ActionServlet servlet
          結びつけられているコントローラServletのインスタンスです。
 
コンストラクタの概要
ActionForm()
           
 
メソッドの概要
 MultipartRequestHandler getMultipartRequestHandler()
          このフォームのMultipartRequestHandlerを返します。
protected  ActionServlet getServlet()
          結びつけられているコントローラServletのインスタンスを返します。
 ActionServletWrapper getServletWrapper()
          結びつけられているコントローラServletのインスタンスを 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のインスタンスをセットします (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
 

フィールドの詳細

servlet

protected transient ActionServlet servlet
結びつけられているコントローラServletのインスタンスです。
The controller servlet instance to which we are attached.


multipartRequestHandler

protected transient MultipartRequestHandler multipartRequestHandler
このフォームのMultipartRequestHandlerです。 nullのこともあります。
The MultipartRequestHandler for this form, can be null.

コンストラクタの詳細

ActionForm

public ActionForm()
メソッドの詳細

getServlet

protected ActionServlet getServlet()
結びつけられているコントローラServletのインスタンスを返します。
Return the controller servlet instance to which we are attached.


getServletWrapper

public ActionServletWrapper getServletWrapper()
結びつけられているコントローラServletのインスタンスを ActionServletWrapperとして返します。
Return the controller servlet instance to which we are attached. as an ActionServletWrapper.

導入されたバージョン:
Struts 1.0.1
関連項目:
ActionServletWrapper

getMultipartRequestHandler

public MultipartRequestHandler getMultipartRequestHandler()
このフォームのMultipartRequestHandlerを返します。 この背景にある理由は、 MultipartRequestHandlerのfinish()メソッドと rollback()メソッドを使用することによって、 フォームBeanの開発者がマルチパートのリクエストのライフサイクルを操作できるようにするためです。 このフォームのenctypeが"multipart/request-data" でない場合はこのメソッドはnullを返します。
[訳注: "multipart/form-data"が正しいと思います。]
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".

関連項目:
MultipartRequestHandler

setServlet

public void setServlet(ActionServlet servlet)
結びつけられているコントローラServletのインスタンスをセットします (servletがnullでない場合)。 また、割り当てられた全てのリソースを解放します (servletがnullである場合)。
Set the controller servlet instance to which we are attached (if servlet is non-null), or release any allocated resources (if servlet is null).

パラメータ:
servlet - もしあれば、新しいコントローラServlet
The new controller servlet, if any

setMultipartRequestHandler

public void setMultipartRequestHandler(MultipartRequestHandler multipartRequestHandler)
ファイルアップロードを扱う際に使用するために与えられたHandlerを設定します。
Set the Handler provides to use in dealing with file uploads.
[訳者コメント: providesはprovidedの間違いと考えて訳しています。]

パラメータ:
multipartRequestHandler - ファイルアップロードに使用するHandler。
The Handler to use for fileuploads.

reset

public void reset(ActionMapping mapping,
                  javax.servlet.ServletRequest request)
Beanの全てのプロパティをデフォルトの状態にリセットします。 このメソッドはコントローラServlet がプロパティを設定する前に呼び出されます。
Reset all bean properties to their default state. This method is called before the properties are repopulated by the controller servlet.

デフォルトの実装はこのメソッドのHTTPバージョンにフォワードします。

The default implementation attempts to forward to the HTTP version of this method.

パラメータ:
mapping - このインスタンスを選択するために用いられたマッピング
The mapping used to select this instance
request - 処理しているServletリクエスト
The servlet request we are processing

reset

public void reset(ActionMapping mapping,
                  javax.servlet.http.HttpServletRequest request)
Beanの全てのプロパティをデフォルトの状態にリセットします。 このメソッドはコントローラServlet がプロパティを設定する前に呼び出されます。
Reset all bean properties to their default state. This method is called before the properties are repopulated by the controller servlet.

デフォルトの実装は何もしません。 サブクラスは全てのBeanプロパティをデフォルトの値にリセットするためにこのメソッドをオーバライドすべきです。

The default implementation does nothing. Subclasses should override this method to reset all bean properties to default values.

「更新」タイプのページに関しては、 このメソッドはフォームの値を初期化する場所としてはふさわしくありません (値の初期化はセットアップ用のActionの中で行なうべきです)。 チェックボックスの値をfalseに設定することについて主に気にする必要がありますが、 ほとんどの場合はこのメソッドを実装しないでおいて構いません。

This method is not the appropriate place to initialize form values 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 - このインスタンスを選択するために用いられたマッピング
The mapping used to select this instance
request - 処理しているServletリクエスト
The servlet request we are processing

validate

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 - このインスタンスを選択するために用いられたマッピング
The mapping used to select this instance
request - 処理しているServletリクエスト
The servlet request we are processing

validate

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 ipmlementation performs no validation and returns null. Subclasses must override this method to provide any validation they wish to perform.

パラメータ:
mapping - このインスタンスを選択するために用いられたマッピング
The mapping used to select this instance
request - 処理しているServletリクエスト
The servlet request we are processing


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