From: <me...@us...> - 2002-10-01 05:12:30
|
Update of /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/classes/formbean In directory usw-pr-cvs1:/tmp/cvs-serv26389/src/tutorials/cayenne-web-app/WEB-INF/classes/formbean Added Files: ArtistForm.java GalleryForm.java PaintingForm.java Log Message: relocated tutorials to a subproject (old tutorials are still around but will be deleted soon) --- NEW FILE: ArtistForm.java --- package formbean; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; public final class ArtistForm extends ActionForm { private String artistName = null; private String dateOfBirth = null; public void setArtistName(String value) { artistName = value; } public String getArtistName() { return artistName; } public void setDateOfBirth(String value) { dateOfBirth = value; } public String getDateOfBirth() { return dateOfBirth; } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { this.artistName = null; this.dateOfBirth = null; } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { System.err.println("****Inside ArtistForm.validate()"); ActionErrors errors = new ActionErrors(); if ((artistName == null) || (artistName.length() < 1)) errors.add("artistName", new ActionError("error.artistname.required")); if (dateOfBirth == null) errors.add("dateOfBirth", new ActionError("No date of birth provided")); return errors; } } --- NEW FILE: GalleryForm.java --- package formbean; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; public final class GalleryForm extends ActionForm { private String galleryName = null; public void setGalleryName(String value) { galleryName = value; } public String getGalleryName() { return galleryName; } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { this.galleryName = null; } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ((galleryName == null) || (galleryName.length() < 1)) errors.add( "galleryName", new ActionError("error.galleryname.required")); return errors; } } --- NEW FILE: PaintingForm.java --- package formbean; import java.math.BigDecimal; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; public final class PaintingForm extends ActionForm { private String paintingTitle = null; private BigDecimal estimatedPrice = null; private String artistName = null; public void setEstimatedPrice(BigDecimal value) { estimatedPrice = value; } public BigDecimal getEstimatedPrice() { return estimatedPrice; } public void setPaintingTitle(String value) { paintingTitle = value; } public String getPaintingTitle() { return paintingTitle; } public void setArtistName(String value) { artistName = value; } public String getArtistName() { return artistName; } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { this.estimatedPrice = null; this.paintingTitle = null; this.artistName = null; } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ((paintingTitle == null) || (paintingTitle.length() < 1)) errors.add("paintingTitle", new ActionError("error.paintingtitle.required")); return errors; } } |