The property id must not be already used in the form.
This field is added to the layout using the {@link #attachField(Object,Field)} method.
6970717273747576777879
tf = new TextField("A field, must match the regular expression a.*b.*c"); tf.addValidator(new RegexpValidator("a.*b.*c", "{0} does not match the regular expression")); tf.setValue("aagsabeqgc"); form.addField("f", tf); tf = new TextField( "A field, must contain the regular expression a.*b.*c"); tf.addValidator(new RegexpValidator("a.*b.*c", false, "{0} does not contain the regular expression"));
7677787980818283848586
tf = new TextField( "A field, must contain the regular expression a.*b.*c"); tf.addValidator(new RegexpValidator("a.*b.*c", false, "{0} does not contain the regular expression")); tf.setValue("aagsabeqgc"); form.addField("g", tf); tf = new TextField( "A field, must match the regular expression ^a.*b.*c$"); tf.addValidator(new RegexpValidator("^a.*b.*c$", false, "{0} does not match the regular expression with ^ and $"));
8384858687888990919293
tf = new TextField( "A field, must match the regular expression ^a.*b.*c$"); tf.addValidator(new RegexpValidator("^a.*b.*c$", false, "{0} does not match the regular expression with ^ and $")); tf.setValue("aagsabeqgc"); form.addField("h", tf); tf = new TextField( "A field, must contain the regular expression ^a.*b.*c$"); tf.addValidator(new RegexpValidator("^a.*b.*c$", false, "{0} does not contain the regular expression with ^ and $"));
90919293949596979899100
tf = new TextField( "A field, must contain the regular expression ^a.*b.*c$"); tf.addValidator(new RegexpValidator("^a.*b.*c$", false, "{0} does not contain the regular expression with ^ and $")); tf.setValue("aagsabeqgc"); form.addField("i", tf); // TODO CompositeValidator tf = new TextField( "A field, must be a floating point number with 4-5 chars"); CompositeValidator cv = new CompositeValidator(CombinationMode.AND,
103104105106107108109110111112113
"String length of '{0}' should be 4-5 characters", 4, 5, false)); cv.addValidator(new DoubleValidator( "{0} must be a floating point number")); tf.addValidator(cv); tf.setValue("12.34"); form.addField("j", tf); tf = new TextField( "A field, must be a floating point number or 4-5 chars"); cv = new CompositeValidator(CombinationMode.OR, "The field must contain a floating point or with 4-5 characters");
115116117118119120121122123124125
"String length of '{0}' should be 4-5 characters", 4, 5, false)); cv.addValidator(new DoubleValidator( "{0} must be a floating point number")); tf.addValidator(cv); tf.setValue("12.34g"); form.addField("jb", tf); // Postal code that must be 5 digits (10000-99999). tf = new TextField("Postal Code"); tf.setColumns(5);
131132133134135136137138139140141
return value.matches("[1-9][0-9]{4}"); } }; tf.addValidator(postalCodeValidator); tf.setValue("12345"); form.addField("k", tf); Button b = new Button("Commit", new ClickListener() { @Override public void buttonClick(ClickEvent event) {
1112131415161718192021
public class FormPrimaryStyleName extends TestBase { @Override protected void setup() { final Form form = new Form(); form.addField("aaa", new TextField()); form.setDescription("This is a form description"); form.setCaption("This is a form caption"); form.setPrimaryStyleName("my-form"); HorizontalLayout formFooter = new HorizontalLayout();
1415161718192021222324
@Override protected void setup() { final Form form = new Form(); final TextField tf = new TextField("Search"); form.addField("searchfield", tf); Button button = new Button("Go"); button.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) {
2122232425262728293031
w.addComponent(f); f.setSizeUndefined(); f.getLayout().setSizeUndefined(); f.setCaption("Test form with a really long caption"); f.addField("foo", new TextField("Foo")); f.addField("bar", new TextField("A bit longer field caption")); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); Button b = new Button("right aligned");