How to achieve two-way data binding in the native GWT?

We have been using GWT for about 4 years. One of the most commonly discussed features not found in native GWTs is data binding. Reading through AngularJs another Google suggestion, I came across http://devgirl.org/2013/03/21/fun-with-angularjs/ . I do not want to use GXT or any other third-party tools. I also want to avoid the solution related to the generator.

  • Is there any way to implement it in a pure field GWT?

  • Is there any specific reason why GWT cannot provide this from BOX?

+4
source share
3 answers

Have you tried GWT Pectin ?

I used it successfully in a larger project some time ago.

+1
source

I suggest you try HexaBinding, which is non-invasive and oriented only to data binding. Here is the link: https://github.com/ltearno/hexa.tools/blob/master/hexa.binding/README.md

It works with pure Java, GWT and will soon work with both Android and JavaFX. It may even work with J2Objc, but not sure yet ...

+1
source

I read the post you mentioned about devgirl about AngularJS. In this post, โ€œtwo-way data bindingโ€ refers to a code property to automatically reflect the view that is happening with the data currently being displayed.

This has been achieved in GWT since version 2.1 with Cell Widgets

The first paragraph of the Cell Widgets documentation above clearly states that:

A cell widget can receive data from any type of data source. The data model processes asynchronous updates, as well as push updates. When you change data, the view is automatically updated.

If you want to do something basic in GWT, as an example in the devGirl post, you need to write an onKeyup handler (in AngularJS you have to write Scope for this purpose), which would copy what you entered on the associated shortcut. Something like that:

... final TextBox nameField = new TextBox(); final Label enteredName = new Label(""); ... public void onKeyUp(KeyUpEvent event) { enteredName.setText(nameField.getText()); } ... 
0
source

All Articles