<div dir="ltr"><div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="background-color:rgb(243,243,243)">Hi all!</span></font></div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="background-color:rgb(243,243,243)">How do I integrate Bean Validation with JavaFX?</span></font></div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="background-color:rgb(243,243,243)"><br></span></font></div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="background-color:rgb(243,243,243)">I would like to make a <b>bidirectional bind</b> between the entity field and the javaFx controllers. In this scenario how could I validate fields using Bean Validation?</span></font></div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="background-color:rgb(243,243,243)"><br></span></font></div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="background-color:rgb(243,243,243)">Ex:</span></font></div></div><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)">public class Category{</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> @NotNull(message = "Name can't be null) </span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> @Size(max = 255, min=3, message = "Size name must be between 255 and 3")</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> private StringProperty name = new SimpleStringProperty();</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> //... getters & setters</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)">}</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)">//some fx Controller...</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)">public class CategoryController{</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> @FXML</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> private TextField textFiledCategoryName; </span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> private Category category;</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> @FXML</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> public void initialize() { </span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> category = new Category();</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> textFiledCategoryName.textProperty().bindBidirectional(category.nameProperty()); </span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)"> }</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)">//other code...</span><br style="margin:0px;padding:0px;color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace"><span style="color:rgb(0,102,0);font-family:Monaco,"Courier New",monospace;background-color:rgb(250,250,250)">}</span><br clear="all"><div><br></div><div>thanks!</div>-- <br><div class="gmail-m_7696402582463435148gmail_signature"><div dir="ltr"><b><i>Rafael A P Nascimento </i></b><div><b><i><a href="http://finalexception.blogspot.com.br" target="_blank">finalexception.blogspot.com</a><br></i></b><div><br></div></div></div></div>
</div>