• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ValidationError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sourceforge.stripes.validation.ValidationError的典型用法代码示例。如果您正苦于以下问题:Java ValidationError类的具体用法?Java ValidationError怎么用?Java ValidationError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ValidationError类属于net.sourceforge.stripes.validation包,在下文中一共展示了ValidationError类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
 * Attempt to parse the input string to an integer and look up the {@link Component} with that
 * ID using a {@link ComponentManager}.
 * 
 * @param input The input string to be parsed as the Component ID.
 * @param targetType The type of object we're supposed to be returning.
 * @param errors The validation errors for this request. If the input string cannot be parsed,
 *            then we will add a new {@link ValidationError} to this collection and return null.
 */
public Component convert(String input, Class<? extends Component> targetType,
        Collection<ValidationError> errors) {
    Component component = null;

    try {
        int id = Integer.valueOf(input);
        ComponentManager componentManager = new ComponentManager();
        component = componentManager.getComponent(id);
    }
    catch (NumberFormatException e) {
        errors.add(new SimpleError("The number {0} is not a valid Component ID", input));
    }

    return component;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:ComponentTypeConverter.java


示例2: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
 * Attempt to parse the input string to an integer and look up the {@link Bug} with that ID
 * using a {@link BugManager}.
 * 
 * @param input The input string to be parsed as the Bug ID.
 * @param targetType The type of object we're supposed to be returning.
 * @param errors The validation errors for this request. If the input string cannot be parsed,
 *            then we will add a new {@link ValidationError} to this collection and return null.
 */
public Bug convert(String input, Class<? extends Bug> targetType,
        Collection<ValidationError> errors) {
    Bug bug = null;

    try {
        int id = Integer.valueOf(input);
        BugManager bugManager = new BugManager();
        bug = bugManager.getBug(id);
    }
    catch (NumberFormatException e) {
        errors.add(new SimpleError("The number {0} is not a valid Bug ID", input));
    }

    return bug;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:BugTypeConverter.java


示例3: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
 * Attempt to parse the input string to an integer and look up the {@link Person} with that ID
 * using a {@link PersonManager}.
 * 
 * @param input The input string to be parsed as the Person ID.
 * @param targetType The type of object we're supposed to be returning.
 * @param errors The validation errors for this request. If the input string cannot be parsed,
 *            then we will add a new {@link ValidationError} to this collection and return null.
 */
public Person convert(String input, Class<? extends Person> targetType,
        Collection<ValidationError> errors) {
    Person person = null;

    try {
        int id = Integer.valueOf(input);
        PersonManager personManager = new PersonManager();
        person = personManager.getPerson(id);
    }
    catch (NumberFormatException e) {
        errors.add(new SimpleError("The number {0} is not a valid Person ID", input));
    }

    return person;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:PersonTypeConverter.java


示例4: doEndTag

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
 * Outputs the error for the current iteration of the parent ErrorsTag.
 *
 * @return EVAL_PAGE in all circumstances
 */
@Override
public int doEndTag() throws JspException {

    Locale locale = getPageContext().getRequest().getLocale();
    JspWriter writer = getPageContext().getOut();

    ErrorsTag parentErrorsTag = getParentTag(ErrorsTag.class);
    if (parentErrorsTag != null) {
        // Mode: sub-tag inside an errors tag
        try {
            ValidationError error = parentErrorsTag.getCurrentError();
            writer.write( error.getMessage(locale) );
        }
        catch (IOException ioe) {
            JspException jspe = new JspException("IOException encountered while writing " +
                "error tag to the JspWriter.", ioe);
            log.warn(jspe);
            throw jspe;
        }
    }

    return EVAL_PAGE;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:29,代码来源:IndividualErrorTag.java


示例5: getVariableInfo

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Returns an array of length two, for the variables exposed. */
@Override
public VariableInfo[] getVariableInfo(TagData data) {
    VariableInfo[]  scriptVars = new VariableInfo[2];

    scriptVars[0] = new VariableInfo("index",
                                     "java.lang.Number",
                                     true,
                                     VariableInfo.NESTED);

    // TODO: ValidationError should expose properties like field name
    scriptVars[1] = new VariableInfo("error",
                                     ValidationError.class.getName(),
                                     true,
                                     VariableInfo.NESTED);

    return scriptVars;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:19,代码来源:ErrorsTagExtraInfo.java


示例6: hasErrors

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Indicates if validation errors exist for the given field of the given {@link ActionBean}. */
public static boolean hasErrors(ActionBean actionBean, String field) {
    if (actionBean == null || field == null)
        return false;

    ActionBeanContext context = actionBean.getContext();
    if (context == null)
        return false;

    ValidationErrors errors = context.getValidationErrors();
    if (errors == null || errors.isEmpty())
        return false;

    List<ValidationError> fieldErrors = errors.get(field);
    return fieldErrors != null && fieldErrors.size() > 0;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:ElFunctions.java


示例7: logValidationErrors

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Log validation errors at DEBUG to help during development. */
public static final void logValidationErrors(ActionBeanContext context) {
    StringBuilder buf = new StringBuilder("The following validation errors need to be fixed:");

    for (List<ValidationError> list : context.getValidationErrors().values()) {
        for (ValidationError error : list) {
            String fieldName = error.getFieldName();
            if (ValidationErrors.GLOBAL_ERROR.equals(fieldName))
                fieldName = "GLOBAL";

            String message;
            try {
                message = error.getMessage(Locale.getDefault());
            }
            catch (MissingResourceException e) {
                message = "(missing resource)";
            }

            buf.append("\n    -> [").append(fieldName).append("] ").append(message);
        }
    }

    log.debug(buf);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:DispatcherHelper.java


示例8: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public DeploymentRun convert(String input, Class<? extends DeploymentRun> targetType,
                             Collection<ValidationError> errors) {

    if (StringUtils.isBlank(input)) {
        errors.add(new LocalizableError("deploymentrunnotfound"));
        return null;
    }
    DeploymentRun obj = objRepository.findOne(input);

    if (obj == null) {
        errors.add(new LocalizableError("deploymentrunnotfound", input));
        return null;
    }

    return obj;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:DeploymentRunConverter.java


示例9: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public UUID convert(String string,
        Class<? extends UUID> type,
        Collection<ValidationError> errors) {
    UUID uuid;
    Matcher matcher = PATTERN.matcher(string);
    if (matcher.find()) {
        try {
            uuid = UUID.fromString(string);
            if (uuid == null) {
                errors.add(UUID_NOT_VALID_ERROR);
            }
            return uuid;
        } catch (Exception exc) {
            errors.add(UUID_NOT_VALID_ERROR);
            return null;
        }
    } else {
        errors.add(UUID_NOT_VALID_ERROR);
        return null;
    }
}
 
开发者ID:nordpos-mobi,项目名称:restaurant-service,代码行数:23,代码来源:UUIDTypeConverter.java


示例10: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public Product convert(String sProductId, Class<? extends Product> productClass,
					   Collection<ValidationError> conversionErrors) {
	Product oProd = null;
	AtrilSession oSes = null;
	try {
		oSes = DAO.getAdminSession("Products");
		oProd = Products.seek(oSes, sProductId);
		oSes.disconnect();
		oSes.close();
		oSes = null;
	} catch (ElementNotFoundException enf) {
		Log.out.error("No product with id "+sProductId+" was found");
		conversionErrors.add(new SimpleError("No product with id "+sProductId+" was found"));			
	} catch (Exception exc) {
		Log.out.error(exc.getClass().getName()+" Products.convert("+sProductId+") "+exc.getMessage());
		conversionErrors.add(new SimpleError(exc.getMessage()));
	} finally {
		if (oSes!=null) {
			if (oSes.isConnected()) oSes.disconnect();
			if (oSes.isOpen()) oSes.close();
		}
	}
	return oProd;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:26,代码来源:Products.java


示例11: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public TicketThumbnail convert(String sId, Class<? extends TicketThumbnail> invThumbClass, Collection<ValidationError> conversionErrors) {
	Log.out.debug("BillNoteThumbnail convert("+sId+")");
	AtrilSession oSes = null;
	TicketThumbnail oBln = null;
	try {
		oSes = DAO.getAdminSession("BillNoteThumbnailTypeConverter");
		oBln = new TicketThumbnail(oSes.getDms(), sId);
	} catch (ElementNotFoundException enfe) {
		Log.out.error("Thumbnail "+sId+" not found "+enfe.getMessage(), enfe);
	} catch (Exception xcpt) {
		Log.out.error(xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
	} finally {
		if (oSes!=null) {
			if (oSes.isConnected()) oSes.disconnect();
			if (oSes.isOpen()) oSes.close();
		}
	}
	return oBln;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:21,代码来源:TicketThumbnail.java


示例12: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public Client convert(String sClientId, Class<? extends Client> clientClass,
					  Collection<ValidationError> conversionErrors) {
	if (sClientId==null) return null;
	if (sClientId.length()==0) return null;
	try {
		AtrilSession oSes = DAO.getAdminSession("Client");
		Client oClnt = new Client(oSes.getDms(), sClientId);
		oSes.disconnect();
		oSes.close();
		oSes = null;
		if (null==oClnt) {
			Log.out.error("No client with id "+sClientId+" was found");
			conversionErrors.add(new SimpleError("No client with id "+sClientId+" was found"));
		}
		return oClnt;
	} catch (Exception exc) {
		Log.out.error(exc.getClass().getName()+" Client.convert("+sClientId+") "+exc.getMessage());
		conversionErrors.add(new SimpleError(exc.getMessage()));
		return null;
	}
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:23,代码来源:Client.java


示例13: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public AccountingAccount convert(String sUuid, Class<? extends AccountingAccount> accountClass,
					   Collection<ValidationError> conversionErrors) {
	try {
		AccountingAccount oAacc = null;
		AtrilSession oSes = DAO.getAdminSession("AccountingAccounts");
		List<Document> oLst = oSes.getDms().query("AccountingAccount$account_uuid='"+sUuid+"'");
		if (!oLst.isEmpty()) {
			oAacc = new AccountingAccount(oSes.getDms(), oLst.get(0).id());
		}
		oSes.disconnect();
		oSes.close();
		oSes = null;
		if (null==oAacc) {
			Log.out.error("No accounting account with uuid "+sUuid+" was found");
			conversionErrors.add(new SimpleError("No accounting account with uuid "+sUuid+" was found"));
		}
		return oAacc;
	} catch (Exception exc) {
		Log.out.error(exc.getClass().getName()+" AccountingAccount.convert("+sUuid+") "+exc.getMessage());
		conversionErrors.add(new SimpleError(exc.getMessage()));
		return null;
	}
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:25,代码来源:AccountingAccounts.java


示例14: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public TaxPayer convert(String sTaxPayerId, Class<? extends TaxPayer> taxPayerClass,
					    Collection<ValidationError> conversionErrors) {
	Log.out.debug("Begin TaxPayer.convert("+sTaxPayerId+")");
	if (sTaxPayerId==null) return null;
	if (sTaxPayerId.length()==0) return null;
	TaxPayer oTxpr = null;
	try {
		AtrilSession oSes = DAO.getAdminSession("TaxPayer");
		oTxpr = new TaxPayer(oSes.getDms(), sTaxPayerId);
		oSes.disconnect();
		oSes.close();
		oSes = null;
		if (null==oTxpr) {
			Log.out.error("No tax payer with id "+sTaxPayerId+" was found");
			conversionErrors.add(new SimpleError("No tax payer with id "+sTaxPayerId+" was found"));
		}
	} catch (Exception exc) {
		Log.out.error(exc.getClass().getName()+" TaxPayer.convert("+sTaxPayerId+") "+exc.getMessage());
		conversionErrors.add(new SimpleError(exc.getMessage()));
	}
	Log.out.debug("End TaxPayer.convert("+sTaxPayerId+") : " + oTxpr);
	return oTxpr;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:25,代码来源:TaxPayer.java


示例15: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public User convert(String sDocId, Class<? extends User> userClass,
					   Collection<ValidationError> conversionErrors) {
	try {			
		AtrilSession oSes = DAO.getAdminSession("User");
		User oUsr = new User(oSes, sDocId);
		oSes.disconnect();
		oSes.close();
		oSes = null;
		return oUsr;
	} catch (Exception exc) {
		Log.out.error(exc.getClass().getName()+" User.convert("+sDocId+") "+exc.getMessage());
		conversionErrors.add(new SimpleError(exc.getMessage()));
		return null;
	}
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:17,代码来源:User.java


示例16: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public InvoiceThumbnail convert(String sId, Class<? extends InvoiceThumbnail> invThumbClass, Collection<ValidationError> conversionErrors) {
	Log.out.debug("InvoiceThumbnail convert("+sId+")");
	AtrilSession oSes = null;
	InvoiceThumbnail oThn = null;
	try {
		oSes = DAO.getAdminSession("InvoiceThumbnailTypeConverter");
		oThn = new InvoiceThumbnail(oSes.getDms(), sId);
	} catch (ElementNotFoundException enfe) {
		Log.out.error("Thumbnail "+sId+" not found "+enfe.getMessage(), enfe);
	} catch (Exception xcpt) {
		Log.out.error(xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
	} finally {
		if (oSes!=null) {
			if (oSes.isConnected()) oSes.disconnect();
			if (oSes.isOpen()) oSes.close();
		}
	}
	return oThn;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:21,代码来源:InvoiceThumbnail.java


示例17: convert

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public BigDecimal convert(String sAmount, Class<? extends BigDecimal> bigdecClass, Collection<ValidationError> conversionErrors) {

	BigDecimal oRetVal = null;
    if (null!=sAmount) {	    	
    	if (sAmount.length()>0) {
    		final int iDot = sAmount.indexOf('.');
    		final int iCom = sAmount.indexOf(',');

    		if (iDot!=0 && iCom!=0) {
    			if (iDot>iCom)
    				sAmount = Gadgets.removeChar(sAmount,',');
    			else
    				sAmount = Gadgets.removeChar(sAmount,'.');
    		} // fi
    
    		sAmount = sAmount.replace(',','.');
	    	try {
	    		oRetVal = new BigDecimal(sAmount);
	    	} catch (NumberFormatException nfe) {
	    		conversionErrors.add(new LocalizableError("converter.bigDecimal.numberFormatException", sAmount));
	    	}
    	}
    }
    return oRetVal;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:27,代码来源:BigDecimalTypeConverter.java


示例18: handleValidationErrors

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Converts errors to HTML and streams them back to the browser. */
public Resolution handleValidationErrors(ValidationErrors errors) throws Exception {
    StringBuilder message = new StringBuilder();

    for (List<ValidationError> fieldErrors : errors.values()) {
        for (ValidationError error : fieldErrors) {
            message.append("<div style=\"color: firebrick;\">");
            message.append(error.getMessage(getContext().getLocale()));
            message.append("</div>");
        }
    }

    return new StreamingResolution("text/html", new StringReader(message.toString()));
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:CalculatorActionBean.java


示例19: getFieldErrors

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
 * Access for the field errors that occurred on the form input this tag represents
 * @return List<ValidationError> the list of validation errors for this field
 */
public List<ValidationError> getFieldErrors() throws StripesJspException {
    if (!fieldErrorsLoaded) {
        loadErrors();
        fieldErrorsLoaded = true;
    }

    return fieldErrors;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:13,代码来源:InputTagSupport.java


示例20: compare

import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
public int compare(ValidationError e1, ValidationError e2) {
    // Identical errors should be suppressed
    if (e1.equals(e2)) {
        return 0;
    }

    String fn1 = e1.getFieldName();
    String fn2 = e2.getFieldName();
    boolean e1Global = fn1 == null || fn1.equals(ValidationErrors.GLOBAL_ERROR);
    boolean e2Global = fn2 == null || fn2.equals(ValidationErrors.GLOBAL_ERROR);

    // Sort globals above non-global errors
    if (e1Global && !e2Global) {
        return -1;
    }
    if (e2Global && !e1Global) {
        return 1;
    }
    if (fn1 == null && fn2 == null) {
        return 0;
    }

    // Then sort by field name, and if field names match make the first one come first
    int result = e1.getFieldName().compareTo(e2.getFieldName());
    if (result == 0) {result = 1;}
    return result;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:28,代码来源:ErrorsTag.java



注:本文中的net.sourceforge.stripes.validation.ValidationError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Utility类代码示例发布时间:2022-05-23
下一篇:
Java OnDrawListener类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap