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


Java IValidatable.error方法代码示例

本文整理汇总了Java中org.apache.wicket.validation.IValidatable.error方法的典型用法代码示例。如果您正苦于以下问题:Java IValidatable.error方法的具体用法?Java IValidatable.error怎么用?Java IValidatable.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.wicket.validation.IValidatable的用法示例。


在下文中一共展示了IValidatable.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
    String title = validatable.getValue();
    if (!Strings.isNullOrEmpty(title)) {
        DSLContext context = Spring.getBean(DSLContext.class);
        LayoutTable table = Tables.LAYOUT.as("table");
        int count = 0;
        if (Strings.isNullOrEmpty(this.documentId)) {
            count = context.selectCount().from(table).where(table.TITLE.eq(title)).fetchOneInto(int.class);
        } else {
            count = context.selectCount().from(table).where(table.TITLE.eq(title)).and(table.LAYOUT_ID.notEqual(this.documentId)).fetchOneInto(int.class);
        }
        if (count > 0) {
            validatable.error(new ValidationError(this, "duplicated"));
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:18,代码来源:LayoutTitleValidator.java

示例2: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
    String title = validatable.getValue();
    if (!Strings.isNullOrEmpty(title)) {
        DSLContext context = Spring.getBean(DSLContext.class);
        SectionTable table = Tables.SECTION.as("table");
        int count = 0;
        if (Strings.isNullOrEmpty(this.documentId)) {
            count = context.selectCount().from(table).where(table.TITLE.eq(title)).fetchOneInto(int.class);
        } else {
            count = context.selectCount().from(table).where(table.TITLE.eq(title)).and(table.SECTION_ID.notEqual(this.documentId)).fetchOneInto(int.class);
        }
        if (count > 0) {
            validatable.error(new ValidationError(this, "duplicated"));
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:18,代码来源:SectionTitleValidator.java

示例3: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
    String name = validatable.getValue();
    if (!Strings.isNullOrEmpty(name)) {
        DSLContext context = Spring.getBean(DSLContext.class);
        RestTable table = Tables.REST.as("table");
        int count = 0;
        if (Strings.isNullOrEmpty(this.documentId)) {
            count = context.selectCount().from(table).where(table.NAME.eq(name)).fetchOneInto(int.class);
        } else {
            count = context.selectCount().from(table).where(table.NAME.eq(name)).and(table.REST_ID.notEqual(this.documentId)).fetchOneInto(int.class);
        }
        if (count > 0) {
            validatable.error(new ValidationError(this, "duplicated"));
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:18,代码来源:RestNameValidator.java

示例4: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
 public void validate(IValidatable<String> validatable) {
     String s1 = p1.getValue();
     String s2 = p2.getValue();

     if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) {
         return;
     }
     
     boolean equal = s1 != null ? s1.equals(s2) : s2 == null;
     if (!equal) {
     	validatable = p1.newValidatable();
     	ValidationError err = new ValidationError();
err.addKey("passwordPanel.error");
validatable.error(err);
     }
 }
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:18,代码来源:PasswordPanel.java

示例5: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<List<FileUpload>> validatable) {
	for (FileUpload fileUpload : validatable.getValue()) {
		String fileUploadExtension = FilenameUtils.getExtension(fileUpload.getClientFileName());
		MediaType fileUploadMediaType = MediaType.fromExtension(fileUploadExtension);
		
		if (fileUploadMediaType == null || !mediaTypes.contains(fileUploadMediaType)) {
			ValidationError error = new ValidationError();
			if (errorResourceKey != null) {
				error.addKey(errorResourceKey);
			}
			error.addKey(this);
			error.setVariable("extensions", Joiner.on(", ").skipNulls().join(Lists.transform(mediaTypes, new Function<MediaType, String>() {
				@Override
				public String apply(MediaType input) {
					return input.extension();
				}
			})));
			error.setVariable("clientFileName", fileUpload.getClientFileName());
			validatable.error(error);
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:24,代码来源:FileUploadMediaTypeValidator.java

示例6: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<List<FileUpload>> validatable) {
	for (FileUpload fileUpload : validatable.getValue()) {
		Bytes fileSize = Bytes.bytes(fileUpload.getSize());
		if (fileSize.greaterThan(maximum)) {
			ValidationError error = new ValidationError();
			if (errorResourceKey != null) {
				error.addKey(errorResourceKey);
			}
			error.addKey(this);
			error.setVariable("maximum", maximum);
			error.setVariable("clientFileName", fileUpload.getClientFileName());
			error.setVariable("size", fileSize);
			validatable.error(error);
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:18,代码来源:FileUploadSizeValidator.java

示例7: error

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
private void error(IValidatable<String> pass, String key, Map<String, Object> params) {
	if (web) {
		ValidationError err = new ValidationError().addKey(key);
		if (params != null) {
			err.setVariables(params);
		}
		pass.error(err);
	} else {
		String msg = LabelDao.getString(key, 1L);
		if (params != null && !params.isEmpty() && !Strings.isEmpty(msg)) {
			for (Map.Entry<String, Object> e : params.entrySet()) {
				msg = msg.replace(String.format("${%s}", e.getKey()), "" + e.getValue());
			}
		}
		log.warn(msg);
		pass.error(new ValidationError(msg));
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:19,代码来源:StrongPasswordValidator.java

示例8: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(final IValidatable<Object> validatable) {
    try {
        final IValidatableBeanPathElement cElement = (IValidatableBeanPathElement) element.getModelElement()
                .getBeanPathElement();
        final Object validatableValue = Components.getValidatableValue(component, validatable);
        final Object convertedValidatableValue = convertValidatableValueToBeanPathValue(cElement, validatableValue);
        final String message = cElement.getValidateElement().validate(convertedValidatableValue);
        if (Strings.isNotBlank(message)) {
            //use translated key or use message as fallback if no translation found
            final String normalizedMessage = normalizeMessage(message);
            final ValidationError error = new ValidationError(normalizedMessage);
            error.addKey(normalizedMessage);
            error.setVariable(TITLE, surroundTitle(element.getTitleModel().getObject()));
            validatable.error(error);
        }
    } finally {
        GuiService.get().processRequestFinally(component);
    }
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:21,代码来源:ModelUtilityValidator.java

示例9: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
public void validate(IValidatable<Object> validatable) {
	Validator validator = HibernateValidatorProperty.validatorFactory.getValidator();
	
	@SuppressWarnings("unchecked")
	Set<ConstraintViolation<Object>> violations = validator.validateValue((Class<Object>)beanModel.getObject().getClass(), propertyName, validatable.getValue());
	
	if(!violations.isEmpty()){
		for(ConstraintViolation<?> violation : violations){
			ValidationError error = new ValidationError(violation.getMessage());
			
			String key = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
			if(getValidatorPrefix()!=null) key = getValidatorPrefix()+"."+key;
			
			error.addKey(key);
			error.setVariables(new HashMap<String, Object>(violation.getConstraintDescriptor().getAttributes()));
			
			//remove garbage from the attributes
			error.getVariables().remove("payload");
			error.getVariables().remove("message");
			error.getVariables().remove("groups");
			
			validatable.error(error);
		}
	}
}
 
开发者ID:premium-minds,项目名称:pm-wicket-utils,代码行数:26,代码来源:HibernateValidatorProperty.java

示例10: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
 public void validate(IValidatable<String> validatable) {
     String s1 = p1.getValue();
     String s2 = p2.getValue();

     if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) {
         return;
     }

     boolean equal = s1 != null ? s1.equals(s2) : s2 == null;
     if (!equal) {
     	validatable = p1.newValidatable();
     	ValidationError err = new ValidationError();
err.addKey("passwordPanel.error");
validatable.error(err);
     }
 }
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:18,代码来源:PasswordPanel.java

示例11: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<T> validatable) {
	String logResult = "No violation";
	if (helper.getValidatorMethod() != null) {
		final String validationError = (String) helper.invokeValidatorMethod(validatable.getValue());
		if (StringUtils.isNotBlank(validationError)) {
			validatable.error(new IValidationError() {
				private static final long serialVersionUID = 1L;

				@Override
				public String getErrorMessage(IErrorMessageSource messageSource) {
					String resourceMessage = messageSource.getMessage(validationError, null);
					if (resourceMessage != null) {
						return resourceMessage;
					} else {
						return validationError;
					}
				}
			});
			logResult = "Violation " + validationError;
		}
		if (log.isDebugEnabled()) {
			log.debug(MessageFormat.format(LOG_ENTRY, helper.getValidatorMethod(), helper.getRef().getDomainClass(), logResult));
		}
	}
}
 
开发者ID:Nocket,项目名称:nocket,代码行数:27,代码来源:NocketValidateMethodValidator.java

示例12: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
public void validate(IValidatable<T> iv) {
	this.violated = false;
	
	Validator validator = factory.getValidator();
	Set<ConstraintViolation<T>> violations = validator.validateValue(propertyClass, propertyName, iv.getValue());
	for (ConstraintViolation<T> v : violations) {
		if (violated) {
			continue;
		}
		iv.error(newValidationError(propertyName, v));
		violated = true;
	}
	
	if(!violated && log.isDebugEnabled()) {
		log.debug(MessageFormat.format(LOG_ENTRY, propertyName, propertyClass, "No violation."));
	};
}
 
开发者ID:Nocket,项目名称:nocket,代码行数:18,代码来源:JSR303Validator.java

示例13: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
    String script = validatable.getValue();
    if (!Strings.isNullOrEmpty(script)) {
        if (script.length() >= "SELECT".length() && script.substring(0, "SELECT".length()).toLowerCase().equals("select")) {
        } else {
            validatable.error(new ValidationError(this, "format"));
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:11,代码来源:QueryScriptValidator.java

示例14: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
    String name = validatable.getValue();
    if (!Strings.isNullOrEmpty(name)) {
        if (!Application.CHARACTERS.contains(name.charAt(0))) {
            validatable.error(new ValidationError(this, "invalid"));
            return;
        }
        if (name.length() > 1) {
            for (int i = 1; i < name.length(); i++) {
                char ch = name.charAt(i);
                if (ch != '_' && !Application.CHARACTERS.contains(ch) && !Application.NUMBERS.contains(ch)) {
                    validatable.error(new ValidationError(this, "invalid"));
                    return;
                }
            }
        }
        int count = 0;
        DSLContext context = Spring.getBean(DSLContext.class);
        CollectionTable table = Tables.COLLECTION.as("table");
        if (Strings.isNullOrEmpty(this.documentId)) {
            count = context.selectCount().from(table).where(table.NAME.eq(name)).fetchOneInto(int.class);
        } else {
            count = context.selectCount().from(table).where(table.NAME.eq(name)).and(table.COLLECTION_ID.notEqual(this.documentId)).fetchOneInto(int.class);
        }
        if (count > 0) {
            validatable.error(new ValidationError(this, "duplicated"));
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:31,代码来源:CollectionNameValidator.java

示例15: validate

import org.apache.wicket.validation.IValidatable; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<String> validatable) {
    String path = validatable.getValue();
    if (!Strings.isNullOrEmpty(path)) {
        if (StringUtils.startsWithIgnoreCase(path, "/api") || StringUtils.equalsIgnoreCase(path, "/")) {
            validatable.error(new ValidationError(this, "invalid"));
            return;
        }

        if (path.length() > 1) {
            for (int i = 1; i < path.length(); i++) {
                char ch = path.charAt(i);
                if (ch == '/' || Application.CHARACTERS.contains(ch) || Application.NUMBERS.contains(ch)) {
                } else {
                    validatable.error(new ValidationError(this, "invalid"));
                    return;
                }
            }
        }
        if (StringUtils.containsIgnoreCase(path, "//")) {
            validatable.error(new ValidationError(this, "invalid"));
            return;
        }
        DSLContext context = Spring.getBean(DSLContext.class);
        PageTable table = Tables.PAGE.as("table");
        int count = 0;
        if (Strings.isNullOrEmpty(this.documentId)) {
            count = context.selectCount().from(table).where(table.PATH.eq(path)).fetchOneInto(int.class);
        } else {
            count = context.selectCount().from(table).where(table.PATH.eq(path)).and(table.PAGE_ID.notEqual(this.documentId)).fetchOneInto(int.class);
        }
        if (count > 0) {
            validatable.error(new ValidationError(this, "duplicated"));
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:37,代码来源:PagePathValidator.java


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