本文整理汇总了Java中org.apache.wicket.validation.IValidationError类的典型用法代码示例。如果您正苦于以下问题:Java IValidationError类的具体用法?Java IValidationError怎么用?Java IValidationError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValidationError类属于org.apache.wicket.validation包,在下文中一共展示了IValidationError类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
/**
* Validation rule : all 3 fields (date,hours,minutes) must be not-null.
* @param form
*/
@Override
public void validate(final Form form) {
final DateTimeField dateTimeField =
(DateTimeField) dateTimeComponents[0];
if (!(dateTimeField.getDate() != null
&& dateTimeField.getHours() != null
&& dateTimeField.getMinutes() != null)) {
ValidationError ve = new ValidationError();
ve.setVariables(DateTimeFormValidator.this.variablesMap());
ve.addMessageKey(resourceKey());
dateTimeComponents[0].error((IValidationError) ve);
}
}
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:20,代码来源:DateTimeFieldPanel.java
示例2: validate
import org.apache.wicket.validation.IValidationError; //导入依赖的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
示例3: newValidationError
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
protected IValidationError newValidationError(String propertyName, ConstraintViolation<T> violation) {
ValidationError ve = new ValidationError();
String key = violation.getMessageTemplate();
if (key != null) {
if (key.startsWith("{")) {
key = this.getMessageKey(key);
ve.addKey(key);
} else {
ve.setMessage(key);
}
} else {
ve.addKey(DEFAULT_KEY);
}
String promptTranslation = null;
if(propertyPrompt != null) {
if(!this.localizationWicket) {
promptTranslation = new I18nPropertyBasedImpl().translate(null, propertyPrompt, propertyPrompt);
}
}
ve.setVariable("label", propertyPrompt != null ? promptTranslation : StringUtils.capitalize(propertyName));
ve.getVariables().putAll(violation.getConstraintDescriptor().getAttributes());
if(log.isDebugEnabled()) {
log.debug(MessageFormat.format(LOG_ENTRY, propertyName, propertyClass, "Violation " + ve.toString()));
}
return ve;
}
开发者ID:Nocket,项目名称:nocket,代码行数:27,代码来源:JSR303Validator.java
示例4: ObjectChoiceControlGroup
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@SuppressWarnings("serial")
public ObjectChoiceControlGroup(String id, IModel<T> model) {
super(id, model);
IModel<List<? extends T>> modelList = new LoadableDetachableModel<List<? extends T>>() {
private static final long serialVersionUID = -3995535290067544541L;
@Override
protected List<T> load() {
if(entityProvider==null) throw new RuntimeException("no entity provider for '"+getPropertyName()+"'");
return (List<T>) entityProvider.load();
}
};
dropDown = new DropDownChoice<T>("input", getModel(), modelList){
@Override
public void error(IValidationError error) {
MessageSource source = new MessageSource();
Serializable message = error.getErrorMessage(source);
super.error(message);
}
};
}
开发者ID:premium-minds,项目名称:wicket-crudifier,代码行数:27,代码来源:ObjectChoiceControlGroup.java
示例5: onInitialize
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected void onInitialize() {
super.onInitialize();
add(new ReviewAppointmentAssistBehavior(projectModel));
add(new IValidator<String>() {
@Override
public void validate(IValidatable<String> validatable) {
try {
ReviewAppointment.parse(validatable.getValue());
} catch (Exception e) {
validatable.error(new IValidationError() {
@Override
public Serializable getErrorMessage(IErrorMessageSource messageSource) {
if (StringUtils.isNotBlank(e.getMessage()))
return e.getMessage();
else
return "Syntax error";
}
});
}
}
});
}
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:29,代码来源:ReviewAppointmentInput.java
示例6: decorate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected IValidationError decorate(IValidationError error, IValidatable<String> validatable) {
super.decorate(error, validatable);
((ValidationError) error).setKeys(Collections.singletonList("common.validator.username.pattern"));
return error;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:UsernamePatternValidator.java
示例7: invalidSchema
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
public void invalidSchema() {
EasyMock.expect(validatable.getValue()).andReturn("https://localhost/test").times(2);
validatable.error(EasyMock.<IValidationError>anyObject()); // expect an error
EasyMock.replay(validatable);
UriValidator validator = new UriValidator("http", "ftp");
validator.validate(validatable);
EasyMock.verify(validatable);
}
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:UriValidatorTest.java
示例8: invalidHostname
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
public void invalidHostname() {
EasyMock.expect(validatable.getValue()).andReturn("https://no host/test").times(2);
validatable.error(EasyMock.<IValidationError>anyObject()); // expect an error
EasyMock.replay(validatable);
UriValidator validator = new UriValidator("http", "ftp");
validator.validate(validatable);
EasyMock.verify(validatable);
}
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:UriValidatorTest.java
示例9: TextFieldControlGroup
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
public TextFieldControlGroup(String id, IModel<T> model) {
super(id, model);
textField = new TextField<T>("input", getModel()){
private static final long serialVersionUID = 4925601760084153117L;
@Override
public void error(IValidationError error) {
MessageSource source = new MessageSource();
Serializable message = error.getErrorMessage(source);
super.error(message);
}
};
}
开发者ID:premium-minds,项目名称:wicket-crudifier,代码行数:16,代码来源:TextFieldControlGroup.java
示例10: JodaInstantControlGroup
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
public JodaInstantControlGroup(String id, IModel<DateTime> model) {
super(id, model);
BootstrapJodaDatepicker<DateTime> datepicker = new BootstrapJodaDatepicker<DateTime>("datepicker"){
private static final long serialVersionUID = -1294334224980199521L;
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if(isEnabledInHierarchy()) tag.append("class", "input-append", " ");
}
};
dateField = new JodaInstantTextField<DateTime>("input", getModel(), DateTime.class){
private static final long serialVersionUID = 4925601760084153117L;
@Override
public void error(IValidationError error) {
MessageSource source = new MessageSource();
Serializable message = error.getErrorMessage(source);
super.error(message);
}
};
datepicker.add(dateField);
datepicker.add(new WebMarkupContainer("icon"){
private static final long serialVersionUID = -4412622222987841668L;
@Override
protected void onConfigure() {
super.onConfigure();
//don't display icon if it is disabled
setVisible(dateField.isEnabledInHierarchy());
}
});
add(new BootstrapControlGroupFeedback("controlGroup").add(datepicker));
}
开发者ID:premium-minds,项目名称:wicket-crudifier,代码行数:41,代码来源:JodaInstantControlGroup.java
示例11: testValidationError
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Test
public void testValidationError() {
CollectionControlGroup<String> ccg = new CollectionControlGroup<String>("test", null);
ccg.getFormComponent().error(new IValidationError() {
private static final long serialVersionUID = 1L;
@Override
public Serializable getErrorMessage(IErrorMessageSource messageSource) {
return "Test error";
}
});
assertEquals(1, ccg.getFormComponent().getFeedbackMessages().size());
assertEquals("Test error", ccg.getFormComponent().getFeedbackMessages().first().getMessage());
}
开发者ID:premium-minds,项目名称:wicket-crudifier,代码行数:16,代码来源:CollectionControlGroupTest.java
示例12: onSave
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected void onSave(AjaxRequestTarget target) {
SearchInterfaceConfig config = configModel.getObject();
boolean valid = true;
if (config.isUseGoogleAnalytics()) {
String googleAnalyticsUA = config.getGoogleAnalyticsUA();
String googleAnalyticsHeader = config.getGoogleAnalyticsHeader();
if (StringUtils.isEmpty(googleAnalyticsUA) || googleAnalyticsUA.equals(SearchInterfaceConfig.GA_UA_PLACEHOLDER)) {
googleAnalyticsUAField.error((IValidationError)new ValidationError().addMessageKey("Required"));
valid = false;
}
if (StringUtils.isEmpty(googleAnalyticsHeader)) {
googleAnalyticsHeaderField.error((IValidationError)new ValidationError().addMessageKey("Required"));
valid = false;
}
}
if (valid) {
EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager();
if (!entityManager.getTransaction().isActive()) {
entityManager.getTransaction().begin();
}
SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils.getSearchInterfaceConfigServices();
searchInterfaceConfigServices.makePersistent(config);
entityManager.getTransaction().commit();
}
}
开发者ID:BassJel,项目名称:Jouve-Project,代码行数:28,代码来源:AdminGoogleAnalyticsPanel.java
示例13: decorate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected IValidationError decorate(IValidationError error, IValidatable<String> validatable) {
((ValidationError) error).setKeys(Collections.singletonList("common.validator.username.pattern"));
return error;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:6,代码来源:AbstractUserPopup.java
示例14: validateModelUtilityValidators
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
/**
* Can be used to manually validate all component models again via their utility validators, thus maybe fetching
* more errors after first synchronization was done
*/
public static void validateModelUtilityValidators(final Component component) {
final Component root = Components.findRoot(component);
final Form<?> form = Components.findForm(root);
FormComponent.visitFormComponentsPostOrder(form, new IVisitor<FormComponent<?>, Void>() {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void component(final FormComponent<?> object, final IVisit<Void> visit) {
if (object.isEnabledInHierarchy() && object.isVisibleInHierarchy() && object.isValid()) {
final HtmlContext context = HtmlContext.get(object);
if (context != null) {
final IHtmlElement<?, ?> element = context.getElementRegistry().getElement(object.getId());
if (element != null) {
for (final IValidator<?> validator : object.getValidators()) {
final IValidator<?> unwrappedValidator;
if (validator instanceof ValidatorAdapter) {
final ValidatorAdapter<?> cValidator = (ValidatorAdapter<?>) validator;
unwrappedValidator = cValidator.getValidator();
} else {
unwrappedValidator = validator;
}
if (unwrappedValidator instanceof ModelUtilityValidator) {
/*
* Need to use current model value instead of the normal validate value, since this
* can be sometimes the wrong value internally inside wicket
*/
final IModel<Object> model = (IModel<Object>) object.getModel();
final Validatable<Object> validatable = new Validatable<Object>(model.getObject());
validatable.setModel(model);
unwrappedValidator.validate((IValidatable) validatable);
for (final IValidationError error : validatable.getErrors()) {
object.error(error);
}
}
}
}
}
}
}
});
}
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:45,代码来源:Components.java
示例15: decorate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
protected IValidationError decorate(IValidationError error, IValidatable<String> validatable)
{
return error;
}
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:5,代码来源:DateFormatValidator.java
示例16: decorate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected IValidationError decorate(IValidationError error, IValidatable<String> validatable) {
((ValidationError) error).setKeys(Collections.singletonList("project.field.name.malformed"));
return error;
}
开发者ID:openwide-java,项目名称:artifact-listener,代码行数:6,代码来源:ProjectFormPopupPanel.java
示例17: decorate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected IValidationError decorate(IValidationError error, IValidatable<String> validatable) {
((ValidationError) error).setKeys(Collections.singletonList("project.version.field.version.malformed"));
return error;
}
开发者ID:openwide-java,项目名称:artifact-listener,代码行数:6,代码来源:ProjectVersionFormPopupPanel.java
示例18: decorate
import org.apache.wicket.validation.IValidationError; //导入依赖的package包/类
@Override
protected IValidationError decorate(IValidationError error, IValidatable<String> validatable) {
((ValidationError) error).setKeys(Collections.singletonList("register.password.malformed"));
return error;
}
开发者ID:openwide-java,项目名称:artifact-listener,代码行数:6,代码来源:PasswordPatternValidator.java
注:本文中的org.apache.wicket.validation.IValidationError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论