Actionform source + Comment translation.
Depressed, the first translation of the document was I lost, and again again. Import Org.apache.struts.upload.MultipartRequestHandler;
Import Javax.servlet.ServletRequest;
Import Javax.servlet.http.HttpServletRequest;
Import java.io.Serializable;
/**
* A actionform is a javabean that can be associated with one or more arbitrary actionmapping. The properties of this bean
* Initialized by the corresponding request before the corresponding Action.execute method call.
*
* When the property of this bean is assigned, the Validate method of the bean before the Action.execute method is called
* will be called, this method is used to verify the user-submitted property values. If an error is found, it returns a message containing the contents of the error.
* error message. The controller returns to the appropriate input form. If there is no error, the Validate method returns NULL.
* The corresponding Action.execute method will be called.
*
* This class must be inherited and used. Subclasses are to provide get and set methods for all bean properties that will be exposed (expose), and
* Rewrite some public or protected methods to provide specific implementations.
*
* Because Actionform is JavaBeans, subclasses also implement serializable according to the JavaBeans specification (serializable
*) interface. In order to use the Actionform related introspection API. , some containers require a form object to satisfy
* All JavaBean specifications.
*
*/
Public abstract class Actionform implements Serializable {
-----------------------------------------------------Instance Variables
/**
* <p>the servlet instance to which we is attached.</p>
*/
protected transient actionservlet servlet = null;
/**
* Multipartrequesthandler
* Multi-Request Processing object for this form. Transient indicates that the property will not be serialized.
*//WZL Note: The function of this object is about combining the classes in the upload package to achieve the upload function of the file.
*//Because there is no contact, so the following methods are no longer translated
*/
protected transient multipartrequesthandler multipartrequesthandler;
-------------------------------------------------------------Properties
/**
* @return The servlet instance to which we is attached.
*/
Protected Actionservlet Getservlet () {
Return (this. servlet);
}
/**
* Actionservletwrapper
* Returns the owning controller servlet as a Actionservletwrapper object.
*//The object also provides the use of Multipartrequesthandler on the servlet.
* @return An instance of Actionservletwrapper
*/
Public Actionservletwrapper Getservletwrapper () {
return new Actionservletwrapper (Getservlet ());
}
/**
* <p>return the <code>MultipartRequestHandler</code> for this form the
* Reasoning behind this was to give form beans developers control over the
* Lifecycle of their multipart requests through the use of the
* <code>finish</code> and/or <code>rollback</code> methods of
* <CODE>MULTIPARTREQUESTHANDLER</CODE>. This method would return
* <code>null</code> If this form ' s enctype are not ' multipart/form-data '.
* </p>
*
* @return The {@link Org.apache.struts.upload.MultipartRequestHandler}
* For the This form.
* @see Org.apache.struts.upload.MultipartRequestHandler
*/
Public Multipartrequesthandler Getmultipartrequesthandler () {
return multipartrequesthandler;
}
/**
* Set the servlet (not empty) instance that belongs to.
*
* @param servlet The new controller servlet, if any
*/
public void Setservlet (Actionservlet servlet) {
this. servlet = servlet;
: Fixme:should This is releasing resources?
}
/**
* <p>set the Handler provided for use on dealing with file uploads.</p>
*
* @param multipartrequesthandler the Handler to use for fileuploads.
*/
public void Setmultipartrequesthandler (
Multipartrequesthandler Multipartrequesthandler) {
this. Multipartrequesthandler = Multipartrequesthandler;
}
---------------------------------------------------------Public Methods
/**
*//Direct call to the following overloaded HTTP.
*/
public void Reset (actionmapping mapping, ServletRequest request) {
try {
Reset (mapping, (httpservletrequest) request);
} catch (ClassCastException e) {
; Fixme:why would this ever happen except a null
}
}
/**
* Used to reset attributes in the bean. This method is called before the property is assigned to the controller.
*
* The default method body is empty, in practice, the only one that needs to be reset is the Checkboxs attribute declared to the form in the session.
* All other attributes are initialized when the domain is declared.
*
* If a form can be placed in a session by multiple requests, you must be very careful
* Reset (reset) value, as mentioned above, for each page that input the contents of the form, the session range must be
* Checkboxs pre-reset to Fales. This is because only if the checkbox is Fales indicates that the customer did not commit the value.
* If a checkbox in a session is not reset in advance, he will never be a fales.
*
* This method is not suitable for assigning an initial value to a form in a "modified" type of page (this should be in setup action). The only thing you need
* The concern is to change the value of the checkbox to Fales. So this method is generally not implemented
*
* @param mapping the mapping used to select this instance
* @param request the servlet request we are processing
*/
public void Reset (actionmapping mapping, HttpServletRequest request) {
Default implementation does nothing
}
/**
*//Direct call to the following overloaded HTTP.
*/
Public actionerrors Validate (actionmapping mapping, ServletRequest request) {
try {
return (Validate (mapping, (httpservletrequest) request));
} catch (ClassCastException e) {
return (NULL);
}
}
/**
* Used to validate the attribute value in the request and return a Actionerrors object that contains the error information found in the validation.
* If validation succeeds, returns null or a Actionerrors object with no error information logged.
*
* The default execution body is empty and returns NULL, and the subclass must override this method to provide the required validation action.
*
* @param mapping the mapping used to select this instance
* @param request the servlet request we are processing
* The error message is returned @return validation failure; Validation succeeds returns null or empty information.
*
* @see Dynaactionform
*/
Public actionerrors Validate (actionmapping mapping,
HttpServletRequest request) {
return (NULL);
}
}