将实体代理绑定到 UI 组件的好方法是什么?
我目前正在开发一个 GWT 项目。问题是,我很难相信我需要一遍又一遍地重复一些样板文件来将数据从 EntityProxy(比如 getSomeData() 方法)绑定到 UI 组件(比如 TextBox)。
你们如何克服这个问题?现在,我必须创建一个从 TextBox 读取并将其设置为 EntityProxy 的方法,以及从 EntityProxy 读取后写入 TextBox 的方法。
基本上,总是一样的!即:
// Update the text box
T someData = entity.getSomeData();
textBox.setText(someData);
// Update the entity
String value = textBox.getText();
entity.setSomeData(value);
你明白我的意思吗?我知道客户端没有反射。我可以使用延迟绑定,但我不确定它如何或是否是 RequestFactory 的 EntityProxys 的好方法。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用您在问题中定义的技术从我的控件中推送和收集数据。最近我发现 GWT 有一个内置功能,名为 编辑器。我还没有机会亲自尝试,但也许你想看看它似乎很有希望。另外,这里还有 Thomas Broyer 博客中关于 编辑器 的另一个有用链接
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