From: <mr...@us...> - 2003-01-08 05:53:51
|
Update of /cvsroot/struts/struts-resume/src/web/org/appfuse/webapp/form In directory sc8-pr-cvs1:/tmp/cvs-serv29690 Added Files: BaseForm.java UploadForm.java Log Message: --- NEW FILE: BaseForm.java --- package org.appfuse.webapp.form; import java.io.Serializable; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import org.apache.struts.validator.ValidatorForm; /** * Base ActionForm bean. An ActionForm bean serves as an adapter to make data * entered into an HTML available to the rest of a Web application, usually by * transferring data to an internal object that uses native types and * implements a business logic interface. * * @author Matt Raible * @version $Revision: 1.1 $ $Date: 2003/01/08 05:53:48 $ */ public class BaseForm extends ValidatorForm implements Serializable { //~ Methods ================================================================ public String toString() { StringBuffer results = new StringBuffer(); Class clazz = getClass(); results.append(getClass().getName() + "\n"); Field[] fields = clazz.getDeclaredFields(); try { AccessibleObject.setAccessible(fields, true); for (int i = 0; i < fields.length; i++) { results.append("\t" + fields[i].getName() + "=" + fields[i].get(this) + "\n"); } } catch (Exception e) { // ignored! } return results.toString(); } } --- NEW FILE: UploadForm.java --- package org.appfuse.webapp.form; import org.apache.struts.upload.FormFile; /** * This class is modeled after the UploadForm from the struts-upload example * application. For more information on implementation details, please * see that application. * * @author Matt Raible * @version $Revision: 1.1 $ $Date: 2003/01/08 05:53:48 $ */ public class UploadForm extends BaseForm { //~ Static fields/initializers ============================================= public static final String ERROR_PROPERTY_MAX_LENGTH_EXCEEDED = "org.appfuse.webapp.MaxLengthExceeded"; //~ Instance fields ======================================================== /** The value of the text the user has sent as form data */ protected String name; /** The file that the user has uploaded */ protected FormFile theFile; //~ Methods ================================================================ /** * Retrieve the name the user has given the uploaded file * * @return the file's name */ public String getName() { return name; } /** * Set the name of the uploaded file (by the user) * * @param name */ public void setName(String name) { this.name = name; } /** * Retrieve a representation of the file the user has uploaded * * @return FormFile the uploaded file */ public FormFile getTheFile() { return theFile; } /** * Set a representation of the file the user has uploaded * * @param theFile the file to upload */ public void setTheFile(FormFile theFile) { this.theFile = theFile; } } |