2 Replies Latest reply on Feb 19, 2014 10:07 AM by razvan_v100

    Errai data binding

    razvan_v100

      Hi,

       

        I have an Errai project configured as here (Chapter 8. Data Binding). The model has a bindable annotation and all the fields are bound. The problem is everytime a do a model.getField() "null" is returned. The other way around (using model.setField("text")) sets both the model and the text field. So everytime my input field is updated the model is not synchronized, when I explicitly use set on the model the synchronisation is successfull.

        Do you have an idea of what could I be doing wrong?

       

      Thanks,

      Razvan

        • 1. Re: Errai data binding
          chaluwa

          Can't tell what U are doing wrong if U don't post some of your code here ...

          • 2. Re: Errai data binding
            razvan_v100

            Okay, I can't post the actual code because of an NDA but I can exemplify. So I have a model like this one:

             

             

            @Bindable

            public class FieldModel {

             

            @FieldConstraint

            private String field;

             

            ... // getter setter here

            }

             

            Then I have a widget like this:

             

            @Templated(Templates.MYTEMPLATE + "#fieldTemplate")

            public class MyWidget{

             

            @Inject

                @Model

                private FieldModel model;

             

             

            @Inject

                @Bound

                @DataField

                private TextBox field;

             

                 // now in here the model does not get updated

                 // I had to implement a hack onKeyEvent and on each keypress I have to make a model.setField("new value"); otherwise model.getValue() returns null

            }

             

            The Errai version I am using is 2.4.3:

            App.GWT.xml is correctly configured to include the databinding inheritance as well as the pom.xml file as described in the http://docs.jboss.org/errai/2.1.0.CR2/errai/reference/html/sid-51282340.html .

             

            I hope this helps,

             

            Best Regards,

            Razvan