/** * Configures the passed text field to fail validation when having empty string values.<br/> Additionally, * configures the passed field to be validated when rendered. * * @param field */ public void configTextFieldForNonEmptyValues(TextField<String> field) { field.setAllowBlank(false); field.setAutoValidate(true); field.setValidator(nonEmptyStringValidator); field.addListener(Events.Render, validatorListener); field.addListener(Events.OnKeyUp, validatorListener); field.addListener(Events.Change, validatorListener); }
public FolderForm() { super(); binding = new FormBinding(this); UiConstants constants = GWT.create(UiConstants.class); nameField = new TextField<String>(); nameField.setFieldLabel(constants.name()); nameField.setMaxLength(PROJECT_MAX_LENGTH); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); binding.addFieldBinding(new FieldBinding(nameField, "name")); this.add(nameField); }
/** * Configures the text field as required: blank/empty strings not allowed, validates on render, and "Required field" * messages are shown when blank/empty.<br/> * @param field */ @SuppressWarnings("unchecked") public void configRequired(TextField<?> field) { field.setAllowBlank(false); field.setValidator(nonEmptyStringsValidator); field.addListener(Events.Render, validatorListener); TextFieldMessages fieldMessages = field.getMessages(); fieldMessages.setInvalidText(messages.vmRequired()); fieldMessages.setBlankText(messages.vmRequired()); }
allowed.remove(model); dialog.getForm().getNameField().setValidator(new UniqueNameValidator(allowed)); dialog.show(new FormDialogCallback() {
@Override public FormDialogTether showAddDialog(ProjectDTO project, FormDialogCallback callback) { ProjectForm form = new ProjectForm(); form.getBinding().bind(project); form.getNameField().setValidator(new UniqueNameValidator(grid.getStore().getModels())); FormDialogImpl<ProjectForm> dlg = new FormDialogImpl<>(form); dlg.setWidth(450); dlg.setHeight(300); dlg.setHeadingText(messages.createProject()); dlg.show(callback); return dlg; }
public PartnerForm(Set<String> existingPartnerName) { super(); binding = new FormBinding(this); UiConstants constants = GWT.create(UiConstants.class); nameField = new TextField<>(); nameField.setFieldLabel(constants.name()); nameField.setMaxLength(PartnerDTO.NAME_MAX_LENGTH); nameField.setAllowBlank(false); nameField.setValidator(new UniqueNameValidator(existingPartnerName)); binding.addFieldBinding(new FieldBinding(nameField, "name")); this.add(nameField); TextField<String> fullField = new TextField<>(); fullField.setFieldLabel(constants.description()); fullField.setMaxLength(64); binding.addFieldBinding(new FieldBinding(fullField, "fullName")); this.add(fullField); }
public ProjectForm() { super(); binding = new FormBinding(this); UiConstants constants = GWT.create(UiConstants.class); nameField = new TextField<String>(); nameField.setFieldLabel(constants.name()); nameField.setMaxLength(PROJECT_MAX_LENGTH); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); binding.addFieldBinding(new FieldBinding(nameField, "name")); this.add(nameField); TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setFieldLabel(constants.description()); descriptionTextArea.setMaxLength(250); binding.addFieldBinding(new FieldBinding(descriptionTextArea, "description")); this.add(descriptionTextArea); }
public AttributeForm() { binding = new FormBinding(this); final NumberField idField = new NumberField(); idField.setFieldLabel("ID"); idField.setReadOnly(true); binding.addFieldBinding(new FieldBinding(idField, "id")); add(idField); TextField<String> nameField = new TextField<String>(); nameField.setFieldLabel(I18N.CONSTANTS.name()); nameField.setMaxLength(AttributeDTO.NAME_MAX_LENGTH); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); binding.addFieldBinding(new OnlyValidFieldBinding(nameField, "name")); add(nameField); hideFieldWhenNull(idField); }
public DatabaseForm(final Dispatcher dispatcher) { binding = new FormBinding(this); TextField<String> nameField = new TextField<String>(); nameField.setFieldLabel(I18N.CONSTANTS.name()); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); nameField.setMaxLength(UserDatabaseDTO.MAX_NAME_LENGTH); binding.addFieldBinding(new FieldBinding(nameField, "name")); add(nameField); TextField<String> fullNameField = new TextField<String>(); fullNameField.setFieldLabel(I18N.CONSTANTS.description()); fullNameField.setMaxLength(50); binding.addFieldBinding(new FieldBinding(fullNameField, "fullName")); add(fullNameField); countryField = new RemoteComboBox<CountryDTO>(); countryField.setStore(createCountryStore(dispatcher, countryField)); countryField.setFieldLabel(I18N.CONSTANTS.country()); countryField.setValueField("id"); countryField.setDisplayField("name"); countryField.setAllowBlank(false); countryField.setEnabled(true); countryField.setTriggerAction(TriggerAction.ALL); binding.addFieldBinding(new FieldBinding(countryField, "country") { @Override public void updateModel() { ((UserDatabaseDTO) model).setCountry((CountryDTO) field.getValue()); } }); add(countryField); }
nameField.setMaxLength(LocationTypeDTO.NAME_MAX_LENGTH); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator());
nameField.setMaxLength(255); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); binding.addFieldBinding(new FieldBinding(nameField, "name")); this.add(nameField);
codeField.setFieldLabel(constants.codeFieldLabel()); codeField.setToolTip(constants.codeFieldLabel()); codeField.setValidator((field, value) -> { if (!Strings.isNullOrEmpty(value) && !FormField.isValidCode(value)) { return constants.invalidCodeMessage(); nameField.setFieldLabel(constants.name()); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); expressionField.setFieldLabel(constants.calculation()); expressionField.setToolTip(constants.calculatedIndicatorExplanation()); expressionField.setValidator((field, value) -> validateExpression(value)); binding.addFieldBinding(new OnlyValidFieldBinding(expressionField, IndicatorDTO.EXPRESSION_PROPERTY)); this.add(expressionField);
nameField.setFieldLabel(constants.name()); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); nameField.setMaxLength(50); this.add(nameField);
nameField.setMaxLength(AttributeGroupDTO.NAME_MAX_LENGTH); nameField.setAllowBlank(false); nameField.setValidator(new BlankValidator()); binding.addFieldBinding(new OnlyValidFieldBinding(nameField, "name"));
nameField.setFieldLabel(I18N.CONSTANTS.name()); nameField.setMaxLength(ActivityFormDTO.NAME_MAX_LENGTH); nameField.setValidator(new BlankValidator());