JIRA中输入验证时,将验证错误“InvalidInputException”写到对应字段顶部,而不是页面顶部。
2013-03-27 17:46
507 查看
JIRA now interrogates the InvalidInputException and puts field specific error messages onto the screen.
NOTE : Its up to the validator to ensure it gets the field names right for the current screen scheme.
For example here is example of a Validator that can put specific errors onto specific fields on the default screen.
参照:https://jira.atlassian.com/browse/JRA-12886
NOTE : Its up to the validator to ensure it gets the field names right for the current screen scheme.
For example here is example of a Validator that can put specific errors onto specific fields on the default screen.
public class EvilValidator implements Validator { public void validate(Map transientVars, Map args, PropertySet ps) throws InvalidInputException { Issue issue = (Issue) transientVars.get("issue"); Map errorMap = new HashMap(); checkForEvil(issue, errorMap); if (errorMap.size() > 0) { InvalidInputException inputException = new InvalidInputException("Evil has been detected"); for (Iterator iterator = errorMap.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); inputException.addError((String) entry.getKey(), (String) entry.getValue()); } throw inputException; } } private void checkForEvil(Issue issue, Map errorMap) { String desc = issue.getDescription(); if (isEvil(desc)) { errorMap.put(IssueFieldConstants.DESCRIPTION, "Evil is incarnate in the description"); } String env = issue.getEnvironment(); if (isEvil(env)) { errorMap.put(IssueFieldConstants.ENVIRONMENT, "Evil is incarnate in the environment"); } String summary = issue.getSummary(); if (isEvil(summary)) { errorMap.put(IssueFieldConstants.SUMMARY, "Evil is incarnate in the summary"); } } private boolean isEvil(final String input) { return input != null && input.indexOf("evil") != -1; } }
参照:https://jira.atlassian.com/browse/JRA-12886
相关文章推荐
- 怎样捕获因字段输入不符EditMask而产生的错误:Invalid input value,use escape key to abandon
- HTML页面输入验证
- 自定义cell的时候出现的错误(用的nib而不是storyboard)invalid nib registered for identifier ((null)) - nib must contain
- 在mybatis字段对应不上出现的小错误
- mysql添加DATETIME类型字段导致Invalid default value错误的问题(转载)
- 登录时第一次输入验证码显示验证码错误。出现的问题:验证码ajax验证时 后台取不到session的值
- js页面字段的必填验证方法
- [原创]java WEB学习笔记71:Struts2 学习之路-- struts2常见的内建验证程序及注意点,短路验证,非字段验证,错误消息的重用
- php中通过设置php.ini(或者写到需要受影响的单个php文件中)使warning,notice等错误报告不在页面中显示
- 访问tomcat 8080端口,被要求输入xdb验证,然后报Unauthorized错误?
- 0.jquery 验证,以及显示出现错误的地方 1.当用jquery.validate与ajax时候特别小心在每句后面的逗号问题,如果不需要的地方加上逗号会造成页面无法进入js验证
- morphia中查询或者更新时出现“对象中没有对应的字段定义”的错误
- php本页面表单输入验证
- 编写jsp页面的时候,直接在页面里输入汉字,保存时出现编码错误
- 网站点击导航栏标题,对应的元素平滑上移以及点击图片或按钮回到页面顶部的特效
- 当你输入信用卡号码的时候,有没有担心输错了而造成损失呢?其实可以不必这么担心,因为并不是一个随便的信用卡号码都是合法的,它必须通过Luhn算法来验证通过。 该校验的过程:1、从卡号最后一位数字开始,逆
- 输入信息页面js验证,提示信息
- Bug5:mapper对应页面参数错误,对页面参数的不了解,地址查找undefined
- [置顶] 分析器错误消息: 此实现不是 Windows 平台 FIPS 验证的加密算法的一部分