当前位置: 首页>>代码示例>>Java>>正文


Java Field.setRequired方法代码示例

本文整理汇总了Java中com.vaadin.ui.Field.setRequired方法的典型用法代码示例。如果您正苦于以下问题:Java Field.setRequired方法的具体用法?Java Field.setRequired怎么用?Java Field.setRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.ui.Field的用法示例。


在下文中一共展示了Field.setRequired方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createField

import com.vaadin.ui.Field; //导入方法依赖的package包/类
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
	Field field = super.createField(item, propertyId, uiContext);
	if (propertyId.equals(FachdefinitionPojo.FACHBEZEICHNUNG_COLUMN)) {
		field.setRequired(true);
	} else if (propertyId.equals(FachdefinitionPojo.FACHTYP_COLUMN)) {
		FossaSelect select = new FossaSelect("Fachtyp: ");
		select.setNullSelectionAllowed(false);
		select.setRequired(true);
		BeanItemContainer<FachtypPojo> fachtypContainer = FachtypPojoContainer.getInstance();
		select.setContainerDataSource(fachtypContainer);
		FachtypPojo currentFachtyp = (FachtypPojo) item.getItemProperty(FachdefinitionPojo.FACHTYP_COLUMN).getValue();
		select.setPropertyDataSource(item.getItemProperty(propertyId));
		for (FachtypPojo fachtyp : fachtypContainer.getItemIds()) {
			select.setItemCaption(fachtyp, fachtyp.getFachtyp());
			if (currentFachtyp != null && fachtyp.getId().equals(currentFachtyp.getId())) {
				select.select(fachtyp);
			}
		}
		return select;
	}
	return field;
}
 
开发者ID:fossaag,项目名称:rolp,代码行数:24,代码来源:FachdefinitionenVerwaltenFormFields.java

示例2: setupField

import com.vaadin.ui.Field; //导入方法依赖的package包/类
/**
 * Setup a renderer field, setting up validators if available.
 * @param property Property
 * @param field Field
 */
protected void setupField(P property, Field<?> field) {
	PropertyColumn<T, P> column = getPropertyColumn(property);
	if (column != null) {
		if (column.isRequired()) {
			field.setRequired(true);
			if (column.getRequiredMessage() != null) {
				field.setRequiredError(LocalizationContext.translate(column.getRequiredMessage(), true));
			}
		}
		column.getValidators().forEach(v -> {
			field.addValidator(v);
		});
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:20,代码来源:DefaultItemListing.java

示例3: changeRequired

import com.vaadin.ui.Field; //导入方法依赖的package包/类
/** Change l'etat obligatoire d'un champs
 * @param field
 * @param isRequired
 */
private void changeRequired(Field<?> field, Boolean isRequired){
	field.setRequired(isRequired);
	if (isRequired){
		field.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
	}else{
		field.setRequiredError(null);
	}
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:13,代码来源:CandidatBacWindow.java

示例4: 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;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:37,代码来源:CustomBeanFieldGroup.java

示例5: createField

import com.vaadin.ui.Field; //导入方法依赖的package包/类
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
	Field field = super.createField(item, propertyId, uiContext);
	if (propertyId.equals(SchuelerPojo.VORNAME_COLUMN)) {
		field.setCaption("Vorname: ");
		field.setRequired(true);
	} else if (propertyId.equals(SchuelerPojo.NAME_COLUMN)) {
		field.setCaption("Name: ");
		field.setRequired(true);
	} else if (propertyId.equals(SchuelerPojo.VERSETZUNGSVERMERK_COLUMN)) {
		field.setCaption((String) item.getItemProperty(SchuelerPojo.VORNAME_COLUMN).getValue());
	}
	return field;
}
 
开发者ID:fossaag,项目名称:rolp,代码行数:15,代码来源:SchuelerVerwaltenFormFields.java

示例6: createField

import com.vaadin.ui.Field; //导入方法依赖的package包/类
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
	Field field = super.createField(item, propertyId, uiContext);
	if (propertyId.equals(KlassePojo.KLASSENNAME_COLUMN)) {
		field.setCaption("Klassenbezeichnung: ");
		field.setRequired(true);
	} 
	else if (propertyId.equals(KlassePojo.KLASSENTYP_COLUMN)) {
		Select select = new Select("Klassentyp: ");
		KlassentypPojoContainer klassentypen = KlassentypPojoContainer.getInstance();	
		select.setContainerDataSource(klassentypen);
		KlassentypPojo currentKlassentyp = (KlassentypPojo) item.getItemProperty(KlassePojo.KLASSENTYP_COLUMN).getValue();
		select.setPropertyDataSource(item.getItemProperty(propertyId));
		for (KlassentypPojo klassentyp : klassentypen.getItemIds()) {
			select.setItemCaption(klassentyp, klassentyp.getKlassentyp());
			if (currentKlassentyp != null && klassentyp.getId().equals(currentKlassentyp.getId())) {
				select.select(klassentyp);
			} else if (currentKlassentyp == null && klassentyp.isKlassenstufenorientiert()) {
				select.select(klassentyp);
			}
		}

		select.setNullSelectionAllowed(false);
		select.setRequired(true);
		return select;
	} 
	return field;	
}
 
开发者ID:fossaag,项目名称:rolp,代码行数:29,代码来源:KlasseAnlegenFormFields.java

示例7: createField

import com.vaadin.ui.Field; //导入方法依赖的package包/类
@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
	Field field = super.createField(item, propertyId, uiContext);
	if (propertyId.equals(FachbezeichnungLebPojo.BEZEICHNUNG_COLUMN)) {
		field.setRequired(true);
	}
	return field;
}
 
开发者ID:fossaag,项目名称:rolp,代码行数:9,代码来源:FachbezeichnungLebVerwaltenFormFields.java

示例8: windowContent

import com.vaadin.ui.Field; //导入方法依赖的package包/类
private VerticalLayout windowContent(Play play) {
	VerticalLayout root = new VerticalLayout();
	root.setMargin(true);

	final FormLayout content = new FormLayout();

	FieldGroup fieldGroup = new BeanFieldGroup<Play>(Play.class);
	fieldGroup.setItemDataSource(new BeanItem<Play>(play));
	content.addComponent(fieldGroup.buildAndBind(I18n.t("plays.name"), "name"));
	content.addComponent(fieldGroup.buildAndBind(I18n.t("plays.call"), "call"));
	content.addComponent(fieldGroup.buildAndBind(I18n.t("plays.description"), "desc"));
	Field<?> typeField = fieldGroup.buildAndBind(I18n.t("plays.type"), "type");
	typeField.setRequired(true);
	content.addComponent(typeField);
	content.addComponent(fieldGroup.buildAndBind(I18n.t("plays.published"), "published"));

	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.addClickListener(event -> {
		try {
			fieldGroup.commit();
			this.savedModel = playbookService.save(play);
			EditPlayWindow.this.close();
			BBPlay.info(I18n.t("saveOk"));
		} catch (CommitException e) {
			BBPlay.error(I18n.t("saveFail"));
		}

	});

	Button cancel = new Button(I18n.t("cancel"));
	cancel.addClickListener(event -> EditPlayWindow.this.close());

	footer.addComponents(footerText, ok, cancel);
	footer.setExpandRatio(footerText, 1);

	root.addComponent(footer);

	return root;
}
 
开发者ID:Horuss,项目名称:bbplay,代码行数:50,代码来源:EditPlayWindow.java


注:本文中的com.vaadin.ui.Field.setRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。