当前位置: 首页>>代码示例>>Java>>正文


Java Validator.validate方法代码示例

本文整理汇总了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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:DynaValidatorForm.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:ValidatorForm.java

示例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;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:34,代码来源:DynaValidatorForm.java

示例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;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:32,代码来源:ValidatorForm.java

示例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;
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:26,代码来源:ActionWrapper.java

示例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);
  }
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:10,代码来源:Validate.java

示例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);
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:58,代码来源:ObjectValidator.java


注:本文中的org.apache.commons.validator.Validator.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。