/** * Sets the value of this text field. If the new value is not equal to * {@code getValue()}, fires a {@link ValueChangeEvent}. Throws * {@code NullPointerException} if the value is null. * * @param value * the new value, not {@code null} * @throws NullPointerException * if {@code value} is {@code null} */ @Override public void setValue(String value) { Objects.requireNonNull(value, "value cannot be null"); setValue(value, false); }
@Override public void setText(String text, int cursorPosition) { updateDiffstate("text", Json.create(text)); lastKnownCursorPosition = cursorPosition; setValue(text, true); } }
private AbstractTextField createInputField(InputWidgetElement iwe) { AbstractTextField field = iwe.getSecret() != null && iwe.getSecret() ? new PasswordField() : new TextField(); if (iwe.getMaxLength() != null) { field.setMaxLength(iwe.getMaxLength()); } if (hasText(iwe.getRegexp()) && hasText(iwe.getRegexp())) { field.addValidator(new RegexpValidator(WidgetDefinitionLoader.replaceXmlEscapeCharacters(iwe.getRegexp()), iwe.getErrorKey() != null ? iwe.getErrorKey() : getMessage("processdata.block.error.regexp").replaceFirst("%s", iwe.getRegexp()))); } if (nvl(iwe.getRequired(), false)) { field.setRequired(true); if (hasText(iwe.getCaption())) { String caption = iwe.getCaption(); if (caption.endsWith(":")) caption = caption.substring(0, caption.length() - 1); field.setRequiredError(getMessage("processdata.block.field-required-error") + " " + caption); } else { field.setRequiredError(getMessage("processdata.block.field-required-error")); } } if (hasText(iwe.getBaseText())) { field.setValue(getMessage(iwe.getBaseText())); } if (hasText(iwe.getPrompt())) { field.setInputPrompt(getMessage(iwe.getPrompt())); } if (iwe.getValue() != null) field.setValue(iwe.getValue()); return field; }