Example usage for com.vaadin.v7.data.util.converter StringToIntegerConverter StringToIntegerConverter

List of usage examples for com.vaadin.v7.data.util.converter StringToIntegerConverter StringToIntegerConverter

Introduction

In this page you can find the example usage for com.vaadin.v7.data.util.converter StringToIntegerConverter StringToIntegerConverter.

Prototype

StringToIntegerConverter

Source Link

Usage

From source file:de.symeda.sormas.ui.configuration.infrastructure.DistrictEditForm.java

License:Open Source License

@Override
protected void addFields() {
    addField(DistrictDto.NAME, TextField.class);
    addField(DistrictDto.EPID_CODE, TextField.class);
    ComboBox region = addField(DistrictDto.REGION, ComboBox.class);
    TextField population = addField(DistrictDto.POPULATION, TextField.class);
    population.setConverter(new StringToIntegerConverter());
    population.setConversionError(// ww w  . ja v a2s.c  o m
            I18nProperties.getValidationError(Validations.onlyNumbersAllowed, population.getCaption()));
    TextField growthRate = addField(DistrictDto.GROWTH_RATE, TextField.class);
    growthRate.setConverter(new StringToFloatConverter());
    growthRate.setConversionError(
            I18nProperties.getValidationError(Validations.onlyDecimalNumbersAllowed, growthRate.getCaption()));

    setRequired(true, DistrictDto.NAME, DistrictDto.EPID_CODE, DistrictDto.REGION);

    region.addItems(FacadeProvider.getRegionFacade().getAllAsReference());

    // TODO: Workaround until cases and other data is properly transfered when infrastructure data changes
    if (!create) {
        region.setEnabled(false);
    }
}

From source file:de.symeda.sormas.ui.configuration.infrastructure.RegionEditForm.java

License:Open Source License

@Override
protected void addFields() {
    addField(RegionDto.NAME, TextField.class);
    addField(RegionDto.EPID_CODE, TextField.class);
    TextField population = addField(RegionDto.POPULATION, TextField.class);
    population.setConverter(new StringToIntegerConverter());
    population.setConversionError(/*from w ww.jav a  2  s.  co  m*/
            I18nProperties.getValidationError(Validations.onlyNumbersAllowed, population.getCaption()));
    TextField growthRate = addField(RegionDto.GROWTH_RATE, TextField.class);
    growthRate.setConverter(new StringToFloatConverter());
    growthRate.setConversionError(
            I18nProperties.getValidationError(Validations.onlyDecimalNumbersAllowed, growthRate.getCaption()));

    setRequired(true, RegionDto.NAME, RegionDto.EPID_CODE);
}