本文整理汇总了Java中com.vaadin.ui.Field.addValidator方法的典型用法代码示例。如果您正苦于以下问题:Java Field.addValidator方法的具体用法?Java Field.addValidator怎么用?Java Field.addValidator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.Field
的用法示例。
在下文中一共展示了Field.addValidator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildAndBindField
import com.vaadin.ui.Field; //导入方法依赖的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: buildAndBind
import com.vaadin.ui.Field; //导入方法依赖的package包/类
/** ajoute le champs ainsi que le validateur, le required, et initialise le field
* @param caption
* @param propertyId
* @return le field
*/
public Field<?> buildAndBind(String caption, String propertyId) {
Field<?> field = super.buildAndBind(caption, propertyId);
if (MethodUtils.getIsNotNull(this.beanType,propertyId)){
field.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
field.setRequired(true);
}
if (field instanceof AbstractTextField) {
((AbstractTextField) field).setNullRepresentation("");
((AbstractTextField) field).setNullSettingAllowed(true);
}
if (field instanceof DateField) {
((DateField)field).setParseErrorMessage(applicationContext.getMessage("validation.parse.date", null, UI.getCurrent().getLocale()));
}
if (field instanceof RequiredIntegerField) {
((RequiredIntegerField)field).setConversionError(applicationContext.getMessage("validation.parse.int", null, UI.getCurrent().getLocale()));
}
if (field instanceof I18nField) {
if (cacheController.getLangueEnServiceWithoutDefault().size()!=0){
field.setRequiredError(applicationContext.getMessage("validation.i18n.obigatoire", null, UI.getCurrent().getLocale()));
}
field.addValidator(new I18nValidator(applicationContext.getMessage("validation.i18n.one.missing", null, UI.getCurrent().getLocale()),
applicationContext.getMessage("validation.i18n.same.lang", null, UI.getCurrent().getLocale())));
}
IRequiredField requiredField = (IRequiredField) field;
requiredField.initField(true);
return field;
}
示例3: buildAndBindField
import com.vaadin.ui.Field; //导入方法依赖的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;
}
示例4: buildAndBindField
import com.vaadin.ui.Field; //导入方法依赖的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;
}
示例5: CandidatAdminWindow
import com.vaadin.ui.Field; //导入方法依赖的package包/类
/**
* Crée une fenêtre d'édition de cptMin
* @param cptMin la cptMin à éditer
*/
public CandidatAdminWindow(CompteMinima cptMin) {
/* Style */
setModal(true);
setWidth(550,Unit.PIXELS);
setResizable(true);
setClosable(true);
/* Layout */
VerticalLayout layout = new VerticalLayout();
layout.setWidth(100, Unit.PERCENTAGE);
layout.setMargin(true);
layout.setSpacing(true);
setContent(layout);
/* Titre */
setCaption(applicationContext.getMessage("candidat.admin.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(CompteMinima.class);
fieldGroup.setItemDataSource(cptMin);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
String caption = applicationContext.getMessage("compteMinima.table." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
field.setWidth(100, Unit.PERCENTAGE);
if (fieldName.equals(CompteMinima_.mailPersoCptMin.getName())){
field.addValidator(new EmailValidator(applicationContext.getMessage("validation.error.mail", null, Locale.getDefault())));
}
formLayout.addComponent(field);
}
RequiredTextField loginField = (RequiredTextField)fieldGroup.getField(CompteMinima_.loginCptMin.getName());
RequiredTextField etuIdField = (RequiredTextField)fieldGroup.getField(CompteMinima_.supannEtuIdCptMin.getName());
layout.addComponent(formLayout);
/* Ajoute les boutons */
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setWidth(100, Unit.PERCENTAGE);
buttonsLayout.setSpacing(true);
layout.addComponent(buttonsLayout);
btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
btnAnnuler.addClickListener(e -> close());
buttonsLayout.addComponent(btnAnnuler);
buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);
btnEnregistrer = new OneClickButton(applicationContext.getMessage("btnSave", null, UI.getCurrent().getLocale()), FontAwesome.SAVE);
btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY);
btnEnregistrer.addClickListener(e -> {
try {
/*Si le code existe dejà --> erreur*/
if (candidatController.isLoginPresent(loginField.getValue(), cptMin) || candidatController.isSupannEtuIdPresent(etuIdField.getValue(), cptMin)){
return;
}
/* Valide la saisie */
fieldGroup.commit();
/* Enregistre la cptMin saisie */
candidatAdminWindowListener.btnOkClick(cptMin);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}