Search code examples
data-bindinggwtrequestfactory

What is a good approach to bind an entityproxy to a UI component?


I'm currently working on a GWT project. The thing is, I find very hard to believe that I need to repeat some boilerplate over and over to bind the data from an EntityProxy (say a getSomeData() method) to a UI component (say a TextBox).

How do you guys overcome this issue? For now I have to create a method to read from the TextBox and set it to the EntityProxy, and a method to write to the TextBox after reading from the EntityProxy.

Basically, it's always the same! i.e.:

// Update the text box
T someData = entity.getSomeData();
textBox.setText(someData);

// Update the entity
String value = textBox.getText();
entity.setSomeData(value);

You get my point? I'm aware there is no Reflection at client side. I could use deffered binding but I'm not sure how or if it is a good approach with RequestFactory's EntityProxys.

Thank you


Solution

  • I use the technique you have defined in your question to push and collect data from my controls. Recently I have found out that there is a built-in feature of GWT called Editors. I didn't have a chance to try it myself yet but perhaps you want to check it out it seems promising. Also here is another useful link from Thomas Broyer's blog about Editors