本文整理汇总了Java中com.vaadin.data.validator.StringLengthValidator类的典型用法代码示例。如果您正苦于以下问题:Java StringLengthValidator类的具体用法?Java StringLengthValidator怎么用?Java StringLengthValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringLengthValidator类属于com.vaadin.data.validator包,在下文中一共展示了StringLengthValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildAndBindField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
@Override
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
Field<?> field = super.buildAndBindField(label, propId, prop);
if (propId.equals(PROP_SERVLET_ROOT))
{
field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 2, 256, false));
}
else if (propId.equals(PROP_HTTP_PORT))
{
field.setWidth(100, Unit.PIXELS);
//((TextField)field).getConverter().
field.addValidator(new Validator() {
private static final long serialVersionUID = 1L;
public void validate(Object value) throws InvalidValueException
{
int portNum = (Integer)value;
if (portNum > 10000 || portNum <= 80)
throw new InvalidValueException("Port number must be an integer number greater than 80 and lower than 10000");
}
});
}
return field;
}
示例2: initValidation
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void initValidation() {
String message = ViewMessages.getMessage("IUI-000003");
commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
if (PCCConstant.LOAD_BALANCER_ELB.equals(loadBalancerType)) {
if (BooleanUtils.isTrue(awsVpc)) {
message = ViewMessages.getMessage("IUI-000029");
securityGroupSelect.setRequired(true);
securityGroupSelect.setRequiredError(message);
message = ViewMessages.getMessage("IUI-000108");
subnetSelect.setRequired(true);
subnetSelect.setRequiredError(message);
}
}
}
示例3: bindPatientNameField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void bindPatientNameField() {
binder.forField(patientName).withValidator(new StringLengthValidator("Too short", 3, 200))
.bind(Patient::getName, (p, name) -> {
p.setName(name);
doctorComponents.stream().forEach(component -> component.registerButton.setEnabled(true));
});
}
开发者ID:mrts,项目名称:vaadin-javaee-clinic-patient-queue-example,代码行数:8,代码来源:RegistrationKioskViewImpl.java
示例4: createTextField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private TextField createTextField(final String in18Key, final String id) {
final TextField textField = new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id)
.buildTextComponent();
textField.setSizeUndefined();
textField.addValidator(
new StringLengthValidator(i18n.getMessage("message.rollout.group.name.invalid"), 1, 64, false));
return textField;
}
示例5: buildAndBindField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
Field<Object> field = (Field<Object>)super.buildAndBindField(label, propId, prop);
if (propId.equals(PROP_STORAGE_PATH))
field.setVisible(false);
else if (propId.equals(PROP_DATASRC_ID))
{
field = makeModuleSelectField(field, IDataProducerModule.class);
field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
}
return field;
}
示例6: buildAndBindField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
Field<Object> field = (Field<Object>)super.buildAndBindField(label, propId, prop);
if (propId.endsWith(PROP_ENDPOINT))
{
field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
}
else if (propId.endsWith(PROP_ENABLED))
{
field.setVisible(true);
}
else if (propId.endsWith(PROP_URI))
{
field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
}
else if (propId.endsWith(PROP_STORAGEID))
{
field = makeModuleSelectField(field, IStorageModule.class);
}
else if (propId.endsWith(PROP_SENSORID))
{
field = makeModuleSelectField(field, ISensorModule.class);
field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
}
else if (propId.endsWith(PROP_DATAPROVIDERS + PROP_SEP + PROP_NAME))
field.setVisible(true);
return field;
}
示例7: initValidation
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void initValidation() {
String message = ViewMessages.getMessage("IUI-000031");
serviceNameField.setRequired(true);
serviceNameField.setRequiredError(message);
serviceNameField.addValidator(new StringLengthValidator(message, -1, 15, false));
serviceNameField.addValidator(new RegexpValidator("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", true, message));
message = ViewMessages.getMessage("IUI-000003");
commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
message = ViewMessages.getMessage("IUI-000032");
diskSizeField.setRequired(true);
diskSizeField.setRequiredError(message);
diskSizeField.addValidator(new RegexpValidator("^[1-9]|[1-9][0-9]{1,2}|1000$", true, message));
}
示例8: initValidation
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void initValidation() {
String message = ViewMessages.getMessage("IUI-000002");
cloudNameField.setRequired(true);
cloudNameField.setRequiredError(message);
cloudNameField.addValidator(new StringLengthValidator(message, 1, 15, false));
cloudNameField.addValidator(new RegexpValidator("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", true, message));
message = ViewMessages.getMessage("IUI-000003");
commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
示例9: initValidation
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void initValidation() {
String message = ViewMessages.getMessage("IUI-000022");
serverNameField.setRequired(true);
serverNameField.setRequiredError(message);
serverNameField.addValidator(new StringLengthValidator(message, -1, 15, false));
serverNameField.addValidator(new RegexpValidator("^[a-z]|[a-z][0-9a-z-]*[0-9a-z]$", true, message));
message = ViewMessages.getMessage("IUI-000003");
commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
示例10: initValidation
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void initValidation() {
String message = ViewMessages.getMessage("IUI-000055");
loadBalancerNameField.setRequired(true);
loadBalancerNameField.setRequiredError(message);
loadBalancerNameField.addValidator(new StringLengthValidator(message, 1, 15, false));
loadBalancerNameField.addValidator(new RegexpValidator("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", true,
message));
message = ViewMessages.getMessage("IUI-000003");
commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
示例11: initValidation
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void initValidation() {
String message = ViewMessages.getMessage("IUI-000003");
commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
message = ViewMessages.getMessage("IUI-000032");
diskSizeField.setRequired(true);
diskSizeField.setRequiredError(message);
diskSizeField.addValidator(new RegexpValidator("^[1-9]|[1-9][0-9]{1,2}|1000$", true, message));
}
示例12: createContent
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
@Override
protected Component createContent(TextField usernameField, PasswordField passwordField, Button loginBtn) {
custom = CustomLayoutExt.createLayout("loginForm");
Resource logoResource = AccountAssetsResolver.createLogoResource(AppUI.getBillingAccount().getLogopath(), 150);
custom.addComponent(new Image(null, logoResource), "logo-here");
custom.addComponent(ELabel.h1(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN))
.withWidthUndefined(), "form-header");
custom.addStyleName("customLoginForm");
custom.addComponent(usernameField, "usernameField");
StringLengthValidator passwordValidator = new StringLengthValidator("Password length must be greater than 6", 6,
Integer.MAX_VALUE, false);
passwordField.addValidator(passwordValidator);
custom.addComponent(passwordField, "passwordField");
rememberMe = new CheckBox(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD),
false);
custom.addComponent(rememberMe, "rememberMe");
loginBtn.setStyleName(WebThemes.BUTTON_ACTION);
loginBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);
custom.addComponent(loginBtn, "loginButton");
MButton forgotPasswordBtn = new MButton(LocalizationHelper.getMessage(AppUI.getDefaultLocale(),
ShellI18nEnum.BUTTON_FORGOT_PASSWORD), clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoForgotPasswordPage(this, null)))
.withStyleName(WebThemes.BUTTON_LINK);
custom.addComponent(forgotPasswordBtn, "forgotLink");
custom.addComponent(ELabel.html(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD,
ShellI18nEnum.OPT_SIGNIN_MYCOLLAB)), "newToUs");
custom.addComponent(ELabel.html(new A("https://www.mycollab.com/pricing/", "_blank").appendText
(LocalizationHelper.getMessage(AppUI.getDefaultLocale(), ShellI18nEnum.ACTION_CREATE_ACCOUNT)).write())
.withWidthUndefined(), "createAccountLink");
return custom;
}
示例13: checkLength
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
/**
* If the Column annotation has a "length" attribute, adds a validator to check for the maximum allowed length.
* @param field
* @param columnAnnotation
*/
public void checkLength(Field field, Column columnAnnotation, Type typeAnnotation) {
if(typeAnnotation != null && !"text".equals(typeAnnotation.type()))
if(AbstractTextField.class.isAssignableFrom(field.getClass())) {
if(columnAnnotation != null) {
field.addValidator(new StringLengthValidator(Constants.uiMaxLengthExceeded(columnAnnotation.length()), 0, columnAnnotation.length(), true));
}
}
}
示例14: buildNameField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void buildNameField() {
if (nameField == null) {
nameField = new TextField(Messages.getString("Caption.Field.Name"));
nameField.setNullRepresentation("");
nameField.setMaxLength(30);
nameField.setRequired(true);
nameField.setRequiredError(Messages.getString("Message.Error.NameRequired"));
nameField.addValidator(
new StringLengthValidator(Messages.getString("Message.Error.NameLength", 4, 30), 4, 30, false));
}
}
示例15: buildGeneratedGroupField
import com.vaadin.data.validator.StringLengthValidator; //导入依赖的package包/类
private void buildGeneratedGroupField() {
if (generatedGroupField == null) {
generatedGroupField = new TextField();
generatedGroupField.setMaxLength(30);
generatedGroupField.setNullRepresentation("");
generatedGroupField.setRequired(true);
generatedGroupField.setRequiredError(Messages.getString("Message.Error.GeneratedGroupRequired"));
generatedGroupField.addValidator(new StringLengthValidator(
Messages.getString("Message.Error.GeneratedGroupLength", 4, 30), 4, 30, false));
}
}