本文整理匯總了Java中com.vaadin.ui.TextField.setRequired方法的典型用法代碼示例。如果您正苦於以下問題:Java TextField.setRequired方法的具體用法?Java TextField.setRequired怎麽用?Java TextField.setRequired使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.ui.TextField
的用法示例。
在下文中一共展示了TextField.setRequired方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPropertyField
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@Override
public Field getPropertyField(FormProperty formProperty) {
final TextField textField = new TextField(getPropertyLabel(formProperty));
textField.setRequired(formProperty.isRequired());
textField.setEnabled(formProperty.isWritable());
textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
if (formProperty.getValue() != null) {
textField.setValue(formProperty.getValue());
}
// Add validation of numeric value
textField.addValidator(new LongValidator("Value must be a long"));
textField.setImmediate(true);
return textField;
}
示例2: addTextFieldValues
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private static TextField addTextFieldValues(final TextField textField, final Resource icon,
final Validator validator) {
textField.setIcon(icon);
textField.setRequired(true);
if (validator != null) {
textField.addValidator(validator);
}
return textField;
}
示例3: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldID
textFieldID = new TextField();
textFieldID.setCaption("Variable ID");
textFieldID.setImmediate(false);
textFieldID.setWidth("-1px");
textFieldID.setHeight("-1px");
textFieldID.setInvalidAllowed(false);
textFieldID.setRequired(true);
textFieldID.setNullRepresentation("");
mainLayout.addComponent(textFieldID);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save and Continue");
buttonSave.setImmediate(false);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例4: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldColumn
textFieldColumn = new TextField();
textFieldColumn.setCaption("Column");
textFieldColumn.setImmediate(false);
textFieldColumn.setDescription("0-based index into CSV line");
textFieldColumn.setWidth("-1px");
textFieldColumn.setHeight("-1px");
textFieldColumn.setRequired(true);
textFieldColumn.setInputPrompt("Eg. ‘0'");
mainLayout.addComponent(textFieldColumn);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(false);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例5: getPropertyField
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@Override
public Field getPropertyField(FormProperty formProperty) {
TextField textField = new TextField(getPropertyLabel(formProperty));
textField.setRequired(formProperty.isRequired());
textField.setEnabled(formProperty.isWritable());
textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
if (formProperty.getValue() != null) {
textField.setValue(formProperty.getValue());
}
return textField;
}
示例6: initForm
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initForm() {
form = new Form();
form.setValidationVisibleOnCommit(true);
form.setImmediate(true);
addComponent(form);
// name
nameField = new TextField(i18nManager.getMessage(Messages.TASK_NAME));
nameField.focus();
nameField.setRequired(true);
nameField.setRequiredError(i18nManager.getMessage(Messages.TASK_NAME_REQUIRED));
form.addField("name", nameField);
// description
descriptionArea = new TextArea(i18nManager.getMessage(Messages.TASK_DESCRIPTION));
descriptionArea.setColumns(25);
form.addField("description", descriptionArea);
// duedate
dueDateField = new DateField(i18nManager.getMessage(Messages.TASK_DUEDATE));
dueDateField.setResolution(DateField.RESOLUTION_DAY);
form.addField("duedate", dueDateField);
// priority
priorityComboBox = new PriorityComboBox(i18nManager);
form.addField("priority", priorityComboBox);
}
示例7: initName
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initName() {
TextField nameField = new TextField(i18nManager.getMessage(Messages.RELATED_CONTENT_NAME));
nameField.focus();
nameField.setRequired(true);
nameField.setRequiredError(i18nManager.getMessage(Messages.RELATED_CONTENT_NAME_REQUIRED));
nameField.setWidth(100, UNITS_PERCENTAGE);
form.addField("name", nameField);
}
示例8: windowContent
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private VerticalLayout windowContent() {
VerticalLayout root = new VerticalLayout();
root.setMargin(true);
final FormLayout content = new FormLayout();
description = new Label(I18n.t("forgetPassword.description"), ContentMode.HTML);
login = new TextField(I18n.t("username") + "/" + I18n.t("email"));
login.setWidth("100%");
login.setRequired(true);
content.addComponent(description);
content.addComponent(login);
root.addComponent(content);
HorizontalLayout footer = new HorizontalLayout();
footer.setWidth("100%");
footer.setSpacing(true);
footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
Label footerText = new Label();
Button ok = new Button(I18n.t("ok"));
ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);
ok.setDisableOnClick(true);
ok.addClickListener(event -> {
if (login.isValid()) {
ok.setEnabled(false);
User user;
try {
user = userService.sendPasswordReset(login.getValue().trim());
if (user != null) {
ForgetPasswordWindow.this.close();
BBPlay.info(I18n.t("forgetPassword.sent"));
} else {
BBPlay.error(I18n.t("forgetPassword.notExist"));
}
} catch (Exception ex) {
BBPlay.error(I18n.t("forgetPassword.error"));
logger.error("Unexpected error while sending password reset", ex);
} finally {
ok.setEnabled(true);
}
}
});
Button cancel = new Button(I18n.t("cancel"));
cancel.addClickListener(event -> ForgetPasswordWindow.this.close());
footer.addComponents(footerText, ok, cancel);
footer.setExpandRatio(footerText, 1);
root.addComponent(footer);
return root;
}
示例9: showAddProjectDialog
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
/**
* Zeige das Projekt-Hinzufuegen-Dialogfenster, bei dem ein Eingabefeld fuer
* den Namen des Projekts und ein Hinzfuege-Button vorhanden ist. Funktion
* bei geklicktem Button siehe Clicklistener in dieser Klasse. Das
* horizontale Layout zur Darstellung besitzt ein Formlayout und den Button,
* die nebeneinander dargestellt werden.
*
* @author Christian Scherer, Mirko Göpfrich
*/
@Override
public void showAddProjectDialog() {
addDialog = new Window("Projekt hinzufügen");
addDialog.setModal(true);
addDialog.setWidth(410, UNITS_PIXELS);
addDialog.setResizable(false);
addDialog.setDraggable(false);
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(false);
FormLayout formLayout = new FormLayout();
formLayout.setMargin(true);
formLayout.setSpacing(true);
//TextFeld für Name dem Formular hinzufügen
tfName = new TextField("Name wählen:");
tfName.setRequired(true);
tfName.addValidator(new StringLengthValidator(
"Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2,
20, false));
tfName.setRequiredError("Pflichtfeld");
tfName.setSizeFull();
formLayout.addComponent(tfName);
//TextArea für Beschreibung dem Formular hinzufügen
taDescription = new TextArea("Beschreibung wählen");
taDescription.setSizeFull();
formLayout.addComponent(taDescription);
//Formular dem Layout hinzufügen
layout.addComponent(formLayout);
//Hinzufüge-Button erstllen und dem Layout hinzufügen
dialogAddBtn = new Button("Hinzufügen", this);
layout.addComponent(dialogAddBtn);
//Layout dem Dialog-Fenster hinzufügen
addDialog.addComponent(layout);
//Dialog dem Hauptfenster hinzufügen
getWindow().addWindow(addDialog);
logger.debug("Hinzufuege-Dialog erzeugt");
}
示例10: showEditProjectDialog
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
/**Methode zur Implementierung des Dialogfensters für Projekt-Änderungen.
*
*/
@Override
public void showEditProjectDialog(Project project) {
editDialog = new Window("Projekt bearbeiten");
editDialog.setModal(true);
editDialog.setWidth(410, UNITS_PIXELS);
editDialog.setResizable(false);
editDialog.setDraggable(false);
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
FormLayout formLayout = new FormLayout();
formLayout.setMargin(true);
formLayout.setSpacing(true);
//TextFeld für Name dem Formular hinzufügen
tfName = new TextField("Name ändern:", project.getName());
tfName.setRequired(true);
tfName.addValidator(new StringLengthValidator(
"Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2,
20, false));
tfName.setRequiredError("Pflichtfeld");
tfName.setSizeFull();
formLayout.addComponent(tfName);
//TextArea für Beschreibung dem Formular hinzufügen
taDescription = new TextArea("Beschreibung ändern:", project.getDescription());
taDescription.setSizeFull();
formLayout.addComponent(taDescription);
//Formular dem Layout hinzufügen
layout.addComponent(formLayout);
//Speichern-Button erstllen und dem Layout hinzufügen
//TODO: ist das korrekt? Gute Frage, I have no idea what u r doing
dialogEditBtn = new Button("Speichern");
layout.addComponent(dialogEditBtn);
dialogEditBtn.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
if (tfName.isValid()) {
boolean succed = presenter.editProject(projects.get(indexEditBtn), (String) tfName.getValue(), (String) taDescription.getValue());
if (succed) {
getWindow().removeWindow(editDialog);
logger.debug("Projekt-bearbeiten Dialog geschlossen");
}
} else {
getWindow().showNotification(
"",
"Projektname ist ein Pflichtfeld. Bitte geben Sie einen Projektnamen an",
Notification.TYPE_ERROR_MESSAGE);
}
}
});
//Layout dem Dialog-Fenster hinzufügen
editDialog.addComponent(layout);
//Dialog dem Hauptfenster hinzufügen
getWindow().addWindow(editDialog);
logger.debug("Bearbeiten-Dialog erzeugt");
}
示例11: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldAttributeID
textFieldAttributeID = new TextField();
textFieldAttributeID.setCaption("Attribute Assignment ID");
textFieldAttributeID.setImmediate(false);
textFieldAttributeID.setWidth("-1px");
textFieldAttributeID.setHeight("-1px");
textFieldAttributeID.setInvalidAllowed(false);
textFieldAttributeID.setRequired(true);
mainLayout.addComponent(textFieldAttributeID);
// textFieldIssuer
textFieldIssuer = new TextField();
textFieldIssuer.setCaption("Issuer (Optional)");
textFieldIssuer.setImmediate(false);
textFieldIssuer.setWidth("-1px");
textFieldIssuer.setHeight("-1px");
textFieldIssuer.setNullSettingAllowed(true);
mainLayout.addComponent(textFieldIssuer);
// tableCategories
tableCategories = new Table();
tableCategories.setCaption("Category (Optional)");
tableCategories.setImmediate(false);
tableCategories.setWidth("100.0%");
tableCategories.setHeight("-1px");
mainLayout.addComponent(tableCategories);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(false);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例12: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldObligationID
textFieldObligationID = new TextField();
textFieldObligationID.setCaption("Obligation ID");
textFieldObligationID.setImmediate(false);
textFieldObligationID.setWidth("-1px");
textFieldObligationID.setHeight("-1px");
textFieldObligationID.setInvalidAllowed(false);
textFieldObligationID.setRequired(true);
textFieldObligationID.setInputPrompt("Eg. urn:com:foo:obligation:sample");
mainLayout.addComponent(textFieldObligationID);
// optionGroupFullfillOn
optionGroupFullfillOn = new OptionGroup();
optionGroupFullfillOn.setCaption("Fulfill On");
optionGroupFullfillOn.setImmediate(false);
optionGroupFullfillOn.setWidth("-1px");
optionGroupFullfillOn.setHeight("-1px");
optionGroupFullfillOn.setInvalidAllowed(false);
optionGroupFullfillOn.setRequired(true);
mainLayout.addComponent(optionGroupFullfillOn);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(true);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例13: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldName
textFieldName = new TextField();
textFieldName.setCaption("Parameter Name");
textFieldName.setImmediate(false);
textFieldName.setWidth("-1px");
textFieldName.setHeight("-1px");
textFieldName.setInvalidAllowed(false);
textFieldName.setRequired(true);
mainLayout.addComponent(textFieldName);
// textFieldValue
textFieldValue = new TextField();
textFieldValue.setCaption("Parameter Value");
textFieldValue.setImmediate(false);
textFieldValue.setWidth("-1px");
textFieldValue.setHeight("-1px");
textFieldValue.setInvalidAllowed(false);
textFieldValue.setRequired(true);
mainLayout.addComponent(textFieldValue);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(true);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例14: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100.0%");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textName
textName = new TextField();
textName.setCaption("Group Name");
textName.setImmediate(false);
textName.setWidth("-1px");
textName.setHeight("-1px");
textName.setRequired(true);
mainLayout.addComponent(textName);
// textDescription
textDescription = new TextArea();
textDescription.setCaption("Group Description");
textDescription.setImmediate(false);
textDescription.setWidth("100.0%");
textDescription.setHeight("-1px");
textDescription.setNullSettingAllowed(true);
mainLayout.addComponent(textDescription);
mainLayout.setExpandRatio(textDescription, 1.0f);
// tablePolicies
tablePolicies = new Table();
tablePolicies.setCaption("Policies");
tablePolicies.setImmediate(false);
tablePolicies.setWidth("-1px");
tablePolicies.setHeight("-1px");
mainLayout.addComponent(tablePolicies);
mainLayout.setExpandRatio(tablePolicies, 1.0f);
// tablePIP
tablePIP = new Table();
tablePIP.setCaption("PIP Configurations");
tablePIP.setImmediate(false);
tablePIP.setWidth("-1px");
tablePIP.setHeight("-1px");
mainLayout.addComponent(tablePIP);
mainLayout.setExpandRatio(tablePIP, 1.0f);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(true);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例15: buildMainLayout
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldAdviceID
textFieldAdviceID = new TextField();
textFieldAdviceID.setCaption("Advice ID");
textFieldAdviceID.setImmediate(false);
textFieldAdviceID.setWidth("-1px");
textFieldAdviceID.setHeight("-1px");
textFieldAdviceID.setInvalidAllowed(false);
textFieldAdviceID.setRequired(true);
textFieldAdviceID.setInputPrompt("Eg. urn:com:foo:advice:sample");
mainLayout.addComponent(textFieldAdviceID);
// optionGroupEffect
optionGroupEffect = new OptionGroup();
optionGroupEffect.setCaption("Applies To");
optionGroupEffect.setImmediate(false);
optionGroupEffect.setWidth("-1px");
optionGroupEffect.setHeight("-1px");
optionGroupEffect.setInvalidAllowed(false);
optionGroupEffect.setRequired(true);
mainLayout.addComponent(optionGroupEffect);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(true);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}