/** * Checks a value against this <code>PatternValidator</code>'s {@link Pattern}. * * @param validatable * the <code>IValidatable</code> to check */ @Override protected Map<String, Object> variablesMap(IValidatable<String> validatable) { final Map<String, Object> map = super.variablesMap(validatable); map.put("pattern", EMAIL_PATTERN); return map; }
/** * @param length * @return a {@link StringValidator} that generates an error if a string is not of a minimum * length */ public static StringValidator minimumLength(int length) { return new StringValidator(length, null); }
/** * Constructor that sets the minimum and maximum length values. * * @param minimum * the minimum length * @param maximum * the maximum length */ public StringValidator(Integer minimum, Integer maximum) { setRange(minimum, maximum); }
private void initComponent() { add(StringValidator.minimumLength(MINIMUM_INPUT_LENGTH)); }
private void init(final String id, final Integer maxLength) { if (maxLength != null && maxLength != -1) { add(StringValidator.maximumLength(maxLength)); // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Field maxlength is produced by StringValidator. } }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); String tagName = tag.getName().toLowerCase(Locale.ROOT); boolean hasLengthAttribute = hasLengthAttribute(tagName); Integer maximum = getMaximum(); if (maximum != null && hasLengthAttribute) { tag.put("maxlength", maximum); } Integer minimum = getMinimum(); if (minimum != null && hasLengthAttribute) { tag.put("minlength", minimum); } }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); addMaxLengthToTag(component, tag, length); } };
public UsernameTextField(String id) { super(id); Injector.get().inject(this); add(StringValidator.minimumLength(3)); setRequired(true); add(new UsernameExistsValidator()); }
private void init(final Integer maxLength) { if (maxLength != null) { add(StringValidator.maximumLength(maxLength)); //add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Done by StringValidator } } }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); String tagName = tag.getName().toLowerCase(Locale.ROOT); boolean hasLengthAttribute = hasLengthAttribute(tagName); Integer maximum = getMaximum(); if (maximum != null && hasLengthAttribute) { tag.put("maxlength", maximum); } Integer minimum = getMinimum(); if (minimum != null && hasLengthAttribute) { tag.put("minlength", minimum); } }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); addMaxLengthToTag(component, tag, getMaximum()); } };
StringValidator.minimumLength(2))); form.add(new TextField<String>("tasktype", new PropertyModel<String>(task, "taskType")).setRequired(true).add( StringValidator.minimumLength(2))); form.add(new Label("taskcreationTimestamp", task.getTaskCreationTimestamp() != null ? task.getTaskCreationTimestamp().toString() : "N/A"));
/** * Checks a value against this <code>PatternValidator</code>'s {@link Pattern}. * * @param validatable * the <code>IValidatable</code> to check */ protected Map variablesMap(IValidatable validatable) { final Map map = super.variablesMap(validatable); map.put("pattern", pattern.pattern()); return map; }
private void init(final String id, final Integer maxLength) { if (maxLength != null) { add(StringValidator.maximumLength(maxLength)); // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Not supported by html textarea! this.maxLength = maxLength; } }
/** * @param length * @return a {@link StringValidator} that generates an error if a string is not of an exact * length */ public static StringValidator exactLength(int length) { return new StringValidator(length, length); }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); addMaxLengthToTag(component, tag, getMaximum()); } };
/** * Constructor that sets the minimum and maximum length values. * * @param minimum * the minimum length * @param maximum * the maximum length */ public StringValidator(Integer minimum, Integer maximum) { setRange(minimum, maximum); }
fc.add(StringValidator.minimumLength(2)); fc.add(new GroupValidator()); form.add(fc);
/** * Checks a value against this <code>PatternValidator</code>'s {@link Pattern}. * * @param validatable * the <code>IValidatable</code> to check */ @Override protected Map<String, Object> variablesMap(IValidatable<String> validatable) { final Map<String, Object> map = super.variablesMap(validatable); map.put("pattern", pattern.pattern()); return map; }
private void init(final String id, final Integer maxLength) { if (maxLength != null) { add(StringValidator.maximumLength(maxLength)); // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Done by StringValidator } }