List of usage examples for com.vaadin.data.validator StringLengthValidator setMaxLength
public void setMaxLength(Integer maxLength)
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
/** * Create a text area with the provided properties. The size is set to * SizeFull and the text area is set to 'immediate' (show changed immediately * to the user)./*from ww w . j a v a2 s .c om*/ * * @param pCaption The caption * @param pInputPrompt The input prompt shown if no value is set * @param pMinLength The min. string length of the text area. The content can * be checked during validation. * @param pMaxLength The max. string length of the text area. The content can * be checked during validation. * * @return The text area */ public static TextArea factoryTextArea(String pCaption, String pInputPrompt, int pMinLength, int pMaxLength) { TextArea theArea = new TextArea(); theArea.setCaption(pCaption); theArea.setImmediate(true); theArea.setSizeFull(); theArea.setInputPrompt(pInputPrompt); theArea.setNullSettingAllowed(false); theArea.setNullRepresentation(""); StringLengthValidator val; if (pMinLength > 0) { val = new StringLengthValidator("The content length of this text area must be between " + pMinLength + " and " + pMaxLength + " characters."); val.setMinLength(pMinLength); } else { val = new StringLengthValidator( "The maximum content length of this text area is " + pMaxLength + " characters."); } val.setMaxLength(pMaxLength); theArea.addValidator(val); return theArea; }
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
/** * Create a text field with the provided properties. In addition, the returned * text field won't allow to set 'null' values by the user and has no * null-representation. Therefore it shows the input prompt when no value is * provided. The height of the text field is left to the default value * ('undefined')./*from ww w. j a va2 s . c o m*/ * * @param pCaption The field caption. * @param pInputPrompt The input prompt shown if no value is set. * @param pWidth The field width (e.g. 100% or 60px). * @param pImmediate The value of the 'immediate' flag. * @param pMinLength The min. string length of the text field. The content can * be checked during validation. * @param pMaxLength The max. string length of the text field. The content can * be checked during validation. * * @return The text field */ public static TextField factoryTextField(String pCaption, String pInputPrompt, String pWidth, boolean pImmediate, int pMinLength, int pMaxLength) { TextField theField = new TextField(); theField.setCaption(pCaption); theField.setImmediate(pImmediate); theField.setWidth(pWidth); theField.setInputPrompt(pInputPrompt); theField.setNullSettingAllowed(false); theField.setNullRepresentation(""); StringLengthValidator val; if (pMinLength > 0) { val = new StringLengthValidator("The content length of this text field must be between " + pMinLength + " and " + pMaxLength + " characters."); val.setMinLength(pMinLength); } else { val = new StringLengthValidator( "The maximum content length of this text field is " + pMaxLength + " characters."); } val.setMaxLength(pMaxLength); theField.addValidator(val); return theField; }
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
/** * Create a password field with the provided properties. In addition, the * returned password field won't allow to set 'null' values by the user and * has no null-representation. As this is a password field, no input prompt is * shown. The height of the text field is left to the default value * ('undefined').//from w w w . ja va 2s .c om * * @param pCaption The field caption. * @param pWidth The field width (e.g. 100% or 60px). * @param pImmediate The value of the 'immediate' flag. * @param pMinLength The min. string length of the text field. The content can * be checked during validation. * @param pMaxLength The max. string length of the text field. The content can * be checked during validation. * * @return The text field */ public static PasswordField factoryPasswordField(String pCaption, String pWidth, boolean pImmediate, int pMinLength, int pMaxLength) { PasswordField theField = new PasswordField(); theField.setCaption(pCaption); theField.setImmediate(pImmediate); theField.setWidth(pWidth); theField.setNullSettingAllowed(false); theField.setNullRepresentation(""); StringLengthValidator val; if (pMinLength > 0) { val = new StringLengthValidator("The content length of this text field must be between " + pMinLength + " and " + pMaxLength + " characters."); val.setMinLength(pMinLength); } else { val = new StringLengthValidator( "The maximum content length of this text field is " + pMaxLength + " characters."); } val.setMaxLength(pMaxLength); theField.addValidator(val); return theField; }