本文整理汇总了Java中org.apache.commons.validator.Validator.validate方法的典型用法代码示例。如果您正苦于以下问题:Java Validator.validate方法的具体用法?Java Validator.validate怎么用?Java Validator.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.validator.Validator
的用法示例。
在下文中一共展示了Validator.validate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
/**
* 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.
* @return <code>ActionErrors</code> object that encapsulates any validation errors.
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
this.setPageFromDynaProperty();
ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
String validationKey = getValidationKey(mapping, request);
Validator validator = Resources.initValidator(validationKey,
this,
application, request,
errors, page);
try {
validatorResults = validator.validate();
} catch (ValidatorException e) {
log.error(e.getMessage(), e);
}
return errors;
}
示例2: validate
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
/**
* 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
* @return <code>ActionErrors</code> object that encapsulates any validation errors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
String validationKey = getValidationKey(mapping, request);
Validator validator = Resources.initValidator(validationKey,
this,
application, request,
errors, page);
try {
validatorResults = validator.validate();
} catch (ValidatorException e) {
log.error(e.getMessage(), e);
}
return errors;
}
示例3: validate
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
/**
* 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.
* @return <code>ActionErrors</code> object that encapsulates any
* validation errors.
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
this.setPageFromDynaProperty();
ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
String validationKey = getValidationKey(mapping, request);
Validator validator =
Resources.initValidator(validationKey, this, application, request,
errors, page);
try {
validatorResults = validator.validate();
} catch (ValidatorException e) {
log.error(e.getMessage(), e);
}
return errors;
}
示例4: validate
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
/**
* 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
* @return <code>ActionErrors</code> object that encapsulates any
* validation errors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
String validationKey = getValidationKey(mapping, request);
Validator validator =
Resources.initValidator(validationKey, this, application, request,
errors, page);
try {
validatorResults = validator.validate();
} catch (ValidatorException e) {
log.error(e.getMessage(), e);
}
return errors;
}
示例5: validateUsingValidator
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
/**
* バリデータによる検証を行います。
*
* @param request
* リクエスト
* @param executeConfig
* 実行設定
* @return エラーメッセージ
*/
protected ActionMessages validateUsingValidator(HttpServletRequest request,
S2ExecuteConfig executeConfig) {
ServletContext application = ServletContextUtil.getServletContext();
ActionMessages errors = new ActionMessages();
String validationKey = actionMapping.getName() + "_"
+ executeConfig.getMethod().getName();
Validator validator = Resources.initValidator(validationKey,
ActionFormUtil.getActionForm(request, actionMapping),
application, request, errors, 0);
try {
validator.validate();
} catch (ValidatorException e) {
throw new RuntimeException(e);
}
return errors;
}
示例6: fixLabels
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
public static void fixLabels(Object bean, ValidatorResources resources, String formName){
try{
Validator validator = new Validator(resources, formName);
validator.setParameter(Validator.BEAN_PARAM, bean);
validator.validate();
}catch(Exception e){
log.error(e);
}
}
示例7: validate
import org.apache.commons.validator.Validator; //导入方法依赖的package包/类
/**
* Validates the value of the specified Field on the target Object
*
* @param object
* @param fieldName
* @return a Set of Validation Error Keys
* @throws ValidationException
*/
public Set<String> validate(Object object, String fieldName)
throws ValidationException
{
try
{
Set<String> errorKeys = new HashSet<String>();
String objectId = object.getClass().getName();
//Setup the Validator
Validator validator = new Validator(this.validatorResources, objectId);
validator.setParameter(Validator.BEAN_PARAM, object);
validator.setFieldName(fieldName);
ValidatorResults results = validator.validate();
Form form = this.validatorResources.getForm(Locale.getDefault(), objectId);
Iterator propertyNames = results.getPropertyNames().iterator();
while(propertyNames.hasNext())
{
String property = (String)propertyNames.next();
ValidatorResult result = results.getValidatorResult(property);
Map actionMap = result.getActionMap();
Iterator keys = actionMap.keySet().iterator();
while (keys.hasNext())
{
String actionName = (String) keys.next();
if (!result.isValid(actionName))
{
Field field = form.getField(property);
Arg[] args = field.getArgs(actionName);
if(args != null)
{
for(int i=0; i<args.length; i++)
{
errorKeys.add(args[i].getKey());
}
}
}
}
}
return errorKeys;
}
catch(Exception e)
{
log.error(this, e);
throw new ValidationException(e);
}
}