List of usage examples for org.apache.wicket.validation CompoundValidator add
public final CompoundValidator<T> add(IValidator<T> validator)
IValidator
to the chain of validators. From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
private TextField<Integer> getMessageIdTextField() { TextField<Integer> textField = new FeedbackTextField<Integer>("messageId"); textField.setRequired(true);/*from www. ja v a 2 s.co m*/ CompoundValidator<Integer> validator = new CompoundValidator<Integer>(); validator.add(new RangeValidator<Integer>(0, 65535)); validator.add(new UniqueMessageIdValidator()); textField.add(validator); textField.setOutputMarkupId(true); textField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { // The id is the key for the message map, so we have to replace it here getConfig().messages.remove(currentMessageId); getConfig().addMessageConfig(currentMessage); currentMessageId = currentMessage.getMessageId(); target.add(currentMessageIdDropdown); // Clear feedback messages target.addChildren(getPage(), FeedbackPanel.class); target.add(getComponent()); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { target.addChildren(getPage(), FeedbackPanel.class); target.add(getComponent()); } }); return textField; }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
private TextField<String> getMessageAliasTextField() { TextField<String> textField = new FeedbackTextField<String>("messageAlias"); textField.setRequired(true);/* w w w . jav a2 s .c om*/ CompoundValidator<String> validator = new CompoundValidator<String>(); validator.add(new PatternValidator("[A-Za-z0-9_]+")); validator.add(StringValidator.lengthBetween(1, 32)); validator.add(new UniqueMessageAliasValidator()); textField.add(validator); textField.setLabel(labelAlias); // Use the same label as the items textField.setOutputMarkupId(true); textField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(currentMessageIdDropdown); target.addChildren(getPage(), FeedbackPanel.class); target.add(getComponent()); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { target.addChildren(getPage(), FeedbackPanel.class); target.add(getComponent()); } }); return textField; }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
private TextField<Integer> getIdTextField() { TextField<Integer> textField = new FeedbackTextField<Integer>("id"); textField.setRequired(true);/* www. ja v a2 s. c o m*/ CompoundValidator<Integer> validator = new CompoundValidator<Integer>(); validator.add(new UniqueListItemValidator<Integer>(textField).setMessageKey("id.UniqueValueValidator")); validator.add(new RangeValidator<Integer>(1, 254)); textField.add(validator); textField.setLabel(labelId); textField.setOutputMarkupId(true); return textField; }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
private TextField<String> getAliasTextField() { TextField<String> textField = new FeedbackTextField<String>("alias"); textField.setRequired(true);/*from w ww .j a v a2 s .c o m*/ CompoundValidator<String> validator = new CompoundValidator<String>(); validator.add(new PatternValidator("[A-Za-z0-9_]+")); validator.add(StringValidator.lengthBetween(1, 32)); validator.add(new UniqueListItemValidator<String>(textField).setMessageKey("alias.UniqueValueValidator")); validator.add(new NonMatchStringValidator(specialAlias)); textField.add(validator); textField.setLabel(labelAlias); textField.setOutputMarkupId(true); textField.setOutputMarkupPlaceholderTag(true); return textField; }