forms - How to validate a field from a BeanItem in Vaadin? -


i'm trying first hello world vaadin right , i'm stuck first simple validated form. i'm using beanitem itemdatasource form, , don't know how add validator bean property.

my problem

how can actual field property in bean? need call addvalidator() on field, can on form.

helloworldform

package vaadinapp.hello;  import com.vaadin.data.util.beanitem; import com.vaadin.ui.alignment; import com.vaadin.ui.button; import com.vaadin.ui.form; import com.vaadin.ui.horizontallayout; import com.vaadin.ui.label; import com.vaadin.ui.verticallayout;  public class helloworldform extends form {     helloworldbean data = new helloworldbean();      public helloworldform() {         setcaption("hello world");         setdescription("this simple form lets enter name , displays greeting.");          setitemdatasource(new beanitem(data));          setfooter(new verticallayout());         getfooter().addcomponent(                 new label("this footer area of form. can use layout here. nice buttons."));         // have button bar in footer.         horizontallayout okbar = new horizontallayout();         okbar.setheight("25px");         getfooter().addcomponent(okbar);         // add ok (commit), reset (discard), , cancel buttons         // form.         button okbutton = new button("ok", this, "commit");         okbar.addcomponent(okbutton);         okbar.setcomponentalignment(okbutton, alignment.top_right);         okbar.addcomponent(new button("reset", this, "discard"));         okbar.addcomponent(new button("cancel"));     } } 

helloworldbean

package vaadinapp.hello;  public class helloworldbean {     string greeting;      public string getgreeting() {         return greeting;     }      public void setgreeting(string greeting) {         this.greeting = greeting;     } } 

you can't add validators property directly. validators have added field (fields in form or standalone texfield forexample).

take @ chapter 5.17.3 in book of vaadin validating form: http://vaadin.com/book/-/page/components.form.html (note there getfield(id) method in form can use instead of fieldfactory)


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -