1 package org.appfuse.webapp.form; 2 3 import java.io.Serializable ; 4 5 import javax.servlet.http.HttpServletRequest ; 6 7 import org.apache.commons.lang.builder.EqualsBuilder; 8 import org.apache.commons.lang.builder.HashCodeBuilder; 9 import org.apache.commons.lang.builder.ToStringBuilder; 10 import org.apache.commons.lang.builder.ToStringStyle; 11 import org.apache.struts.Globals; 12 import org.apache.struts.action.ActionErrors; 13 import org.apache.struts.action.ActionMapping; 14 import org.apache.struts.util.MessageResources; 15 import org.apache.struts.validator.ValidatorForm; 16 17 18 29 public class BaseForm extends ValidatorForm implements Serializable { 30 private static final long serialVersionUID = 3257005453799404851L; 31 32 public String toString() { 33 return ToStringBuilder.reflectionToString(this, 34 ToStringStyle.MULTI_LINE_STYLE); 35 } 36 37 public boolean equals(Object o) { 38 return EqualsBuilder.reflectionEquals(this, o); 39 } 40 41 public int hashCode() { 42 return HashCodeBuilder.reflectionHashCode(this); 43 } 44 45 56 public ActionErrors validate(ActionMapping mapping, 57 HttpServletRequest request) { 58 String parameter = mapping.getParameter(); 60 61 if (parameter != null) { 62 String method = request.getParameter(parameter); 64 MessageResources resources = 65 (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); 66 67 String cancel = resources.getMessage("button.cancel"); 69 String delete = resources.getMessage("button.delete"); 70 71 if ((method != null) && 74 (method.equalsIgnoreCase(cancel) || 75 method.equalsIgnoreCase(delete))) { 76 return null; 77 } 78 } 79 80 return super.validate(mapping, request); 82 } 83 } 84 | Popular Tags |