1 package com.blandware.atleap.webapp.form; 2 3 import org.apache.commons.lang.builder.EqualsBuilder; 4 import org.apache.commons.lang.builder.HashCodeBuilder; 5 import org.apache.commons.lang.builder.ToStringBuilder; 6 import org.apache.commons.lang.builder.ToStringStyle; 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 import org.apache.struts.Globals; 10 import org.apache.struts.action.ActionErrors; 11 import org.apache.struts.action.ActionMapping; 12 import org.apache.struts.util.MessageResources; 13 import org.apache.struts.validator.ValidatorForm; 14 15 import javax.servlet.http.HttpServletRequest ; 16 import java.io.Serializable ; 17 18 19 28 public class BaseForm extends ValidatorForm implements Serializable { 29 30 33 protected transient final Log log = LogFactory.getLog(getClass()); 34 35 37 public String toString() { 38 return ToStringBuilder.reflectionToString(this, 39 ToStringStyle.MULTI_LINE_STYLE); 40 } 41 42 public boolean equals(Object o) { 43 return EqualsBuilder.reflectionEquals(this, o); 44 } 45 46 public int hashCode() { 47 return HashCodeBuilder.reflectionHashCode(this); 48 } 49 50 61 public ActionErrors validate(ActionMapping mapping, 62 HttpServletRequest request) { 63 String parameter = mapping.getParameter(); 65 66 if ( parameter != null ) { 67 String method = request.getParameter(parameter); 69 MessageResources resources = 70 (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); 71 72 String cancel = resources.getMessage("core.commons.buttons.cancel"); 74 String delete = resources.getMessage("core.commons.buttons.delete"); 75 76 if ( (method != null) && 79 (method.equalsIgnoreCase(cancel) || 80 method.equalsIgnoreCase(delete)) ) { 81 return null; 82 } 83 } 84 85 return super.validate(mapping, request); 87 } 88 } 89 | Popular Tags |