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


Java DateField.setRequired方法代码示例

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


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

示例1: createForm

import com.vaadin.ui.DateField; //导入方法依赖的package包/类
private FormLayout createForm() {
	TextField numberTextField = new TextField("Number");
	numberTextField.setRequired(true);
	numberTextField.setRequiredError("Please enter a flight number!");
	numberTextField.setNullRepresentation("");
	numberTextField.addValidator(new RegexpValidator("\\w\\w\\d\\d\\d", "Please enter a valid flight number!"));

	TextField airlineTextField = new TextField("Airline");
	airlineTextField.setRequired(true);
	airlineTextField.setRequiredError("Please enter an airline!");
	airlineTextField.setNullRepresentation("");

	ComboBox departureAirportField = new ComboBox("Departure Airport");
	departureAirportField.setTextInputAllowed(false);
	departureAirportField.setRequired(true);
	departureAirportField.setRequiredError("Please select a depature airport!");
	departureAirportField.setItemCaptionPropertyId("name");
	departureAirportField.setContainerDataSource(airportContainer);

	ComboBox destinationAirportField = new ComboBox("Destination Airport");
	destinationAirportField.setTextInputAllowed(false);
	destinationAirportField.setRequired(true);
	destinationAirportField.setRequiredError("Please select a destination airport!");
	destinationAirportField.setItemCaptionPropertyId("name");
	destinationAirportField.setContainerDataSource(airportContainer);

	TextField priceField = new TextField("Price");
	priceField.setRequired(true);
	priceField.setRequiredError("Please enter a price!");
	priceField.setNullRepresentation("");
	priceField.setConverter(new StringToBigDecimalConverter());
	priceField.addValidator(new BigDecimalRangeValidator("Please enter a valid price!", new BigDecimal("0.01"), null));

	DateField departureField = new DateField("Departure Date");
	departureField.setDateFormat("dd.MM.yyyy");
	departureField.setRequired(true);
	departureField.setRequiredError("Please enter a departure date!");
	departureField.addValidator(new DateRangeValidator("Please enter departure date in the future!", new Date(), null, Resolution.DAY));

	flightFieldGroup.bind(numberTextField, "number");
	flightFieldGroup.bind(airlineTextField, "airline");
	flightFieldGroup.bind(departureAirportField, "departureAirport");
	flightFieldGroup.bind(destinationAirportField, "destinationAirport");
	flightFieldGroup.bind(priceField, "price");
	flightFieldGroup.bind(departureField, "date");

	return new FormLayout(numberTextField, airlineTextField, departureAirportField, destinationAirportField, priceField, departureField);
}
 
开发者ID:sboe0705,项目名称:flightservice,代码行数:49,代码来源:FlightMaintenanceView.java


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