📄 baseform.java
字号:
/*
* Created on 2006-2-16
*/
package com.base;
import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.struts.validator.LazyValidatorForm;
import org.apache.struts.validator.ValidatorForm;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: epro</p>
* @author tommy.zeng
* @version 1.0
*/
public class BaseForm extends LazyValidatorForm implements Serializable {
private static final long serialVersionUID = 3257005453799404851L;
public String toString() {
return ToStringBuilder.reflectionToString(this,
ToStringStyle.MULTI_LINE_STYLE);
}
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
/**
* This validation method is designed to be a parent of all other Form's
* validate methods - this allows the cancel and delete buttons to bypass
* validation.
*
* @param mapping The <code>ActionMapping</code> used to select this
* instance
* @param request The servlet request we are processing
* @return <code>ActionErrors</code> object that encapsulates any
* validation errors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// Identify the request parameter containing the method name
String parameter = mapping.getParameter();
if (parameter != null) {
// Identify the method name to be dispatched to.
String method = request.getParameter(parameter);
MessageResources resources =
(MessageResources) request.getAttribute(Globals.MESSAGES_KEY);
// Identify the localized message for the cancel button
String cancel = resources.getMessage("button.cancel");
String delete = resources.getMessage("button.delete");
// if message resource matches the cancel button then no
// need to validate
if ((method != null) &&
(method.equalsIgnoreCase(cancel) ||
method.equalsIgnoreCase(delete))) {
return null;
}
}
// perform regular validation
return super.validate(mapping, request);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -