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


Java IValidatable类代码示例

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


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

示例1: onInitialize

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new INullAcceptingValidator<T>() {

		@Override
		public void validate(IValidatable<T> validatable) {
			Validator validator = AppLoader.getInstance(Validator.class);
			Set<?> violations = validator.validateValue(
					propertyDescriptor.getBeanClass(), 
					propertyDescriptor.getPropertyName(), 
					validatable.getValue());
			
			for (Object each: violations) {
				ConstraintViolation<?> violation = (ConstraintViolation<?>) each;
				addError(violation.getMessage());
			}
		}
		
	});
	
	add(new AttributeAppender("class", " property editor editable"));
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:25,代码来源:PropertyEditor.java

示例2: onInitialize

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new IValidator<T>() {

		@Override
		public void validate(IValidatable<T> validatable) {
			Validator validator = AppLoader.getInstance(Validator.class);
			for (ConstraintViolation<T> violation: validator.validate(validatable.getValue())) {
				ValuePath valuePath = new ValuePath(violation.getPropertyPath());
				if (!valuePath.getElements().isEmpty()) {
					PathSegment.Property property = (Property) valuePath.getElements().iterator().next();
					if (!propertyNames.contains(property.getName()))
						continue;
				}
				ErrorContext errorContext = getErrorContext(valuePath);
				errorContext.addError(violation.getMessage());
			}
		}
		
	});
	
	add(AttributeAppender.append("class", " bean editor editable"));
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:26,代码来源:BeanEditor.java

示例3: 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

示例4: 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

示例5: 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

示例6: createObjectClassValidator

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
protected IValidator<String> createObjectClassValidator(final IModel<List<QName>> model){
    return new IValidator<String>() {

        @Override
        public void validate(IValidatable<String> validated) {
            String value = validated.getValue();
            List<QName> list = model.getObject();
            List<String> stringList = new ArrayList<>();

            for(QName q: list){
                stringList.add(q.getLocalPart());
            }

            if(!stringList.contains(value)){
                error(createStringResource("SchemaHandlingStep.message.validationError", value).getString());
                AjaxRequestTarget target = getRequestCycle().find(AjaxRequestTarget.class);
                target.add(getPageBase().getFeedbackPanel());
            }
        }
    };
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:WizardStep.java

示例7: createTextPanel

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private <J> Component createTextPanel(String componentId, final IModel<J> model, String expression,
		final Boolean mandatory) {
	TextPanel<String> textPanel = new TextPanel<String>(componentId, new PropertyModel<String>(model, expression));
	FormComponent input = textPanel.getBaseFormComponent();
	input.add(new AttributeAppender("style", "width: 100%"));
	input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
	input.add(new IValidator() {

		private static final long serialVersionUID = 1L;
		@Override
		public void validate(IValidatable validatable) {
			if (!mandatory) {
				return;
			}
			if (validatable.getValue() == null) {
				validatable.error(new ValidationError("JasperReportConfigurationPanel.errormsg"));
			}
		}

	});
	return textPanel;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:24,代码来源:JasperReportConfigurationPanel.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: validate

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
@Override
public void validate(IValidatable<String> pass) {
	if (badLength(pass.getValue())) {
		error(pass, "bad.password.short", new MicroMap<String, Object>("0", minLength));
	}
	if (noLowerCase(pass.getValue())) {
		error(pass, "bad.password.lower");
	}
	if (noUpperCase(pass.getValue())) {
		error(pass, "bad.password.upper");
	}
	if (noDigit(pass.getValue())) {
		error(pass, "bad.password.digit");
	}
	if (noSymbol(pass.getValue())) {
		error(pass, "bad.password.special");
	}
	if (hasStopWords(pass.getValue())) {
		error(pass, "bad.password.stop");
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:22,代码来源:StrongPasswordValidator.java

示例13: validate

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
@Override
public void validate(final IValidatable<Object> validatable) {
    // Check value against pattern
    final Object value = Components.getValidatableValue(component, validatable);
    if (value != null) {
        for (final Pattern pattern : PATTERNS) {
            if (pattern.matcher(value.toString()).matches()) {
                final ValidationError error = new ValidationError();
                error.setVariable("label",
                        ModelUtilityValidator.surroundTitle(formComponent.getLabel().getObject()));
                error.addKey(getClass().getSimpleName() + "." + "error");
                validatable.error(error);
            }
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:17,代码来源:SQLInjectionValidator.java

示例14: 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

示例15: onValidate

import org.apache.wicket.validation.IValidatable; //导入依赖的package包/类
/**
 * @see AbstractValidator#onValidate(IValidatable)
 */
protected void onValidate(IValidatable validatable)
{
	//setup list
	List<String> regexs = new ArrayList<String>();
	regexs.add("\\+?([0-9]+|\\s+)+(\\w+)?+"); //matches 1,2,3,5 with 10
	regexs.add("\\({1}[0-9]+\\){1}([0-9]+|\\s+)+(\\w+)?+"); //matches 4 with 10
	regexs.add("([0-9]+(\\-|\\.)?)+(\\w+)?+"); //matches 6, 7 with 10
	regexs.add("\\({1}[0-9]+\\){1}([0-9]+|\\s+|\\-?|\\.?)+(\\w+)?+"); //matches 8,9 with 10
	
	//check each, if none, error
	for(String r: regexs) {
		Pattern p = Pattern.compile(r);
		if (p.matcher((String)validatable.getValue()).matches()) {
			return;
		}
	}
	
	//if we haven't matched, error.
	error(validatable);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:24,代码来源:PhoneNumberValidator.java


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