GWT 请求工厂中的实体代理更改侦听器
我希望使用请求工厂代理实现 UI 和数据的双向绑定,对于这一部分,我需要一种方法来侦听 EntityProxy 或 ValueProxy 中的更改。如果它们是普通模型,我可以将我的视图附加到模型的更改侦听器,但在请求工厂中,模型或“代理”是接口,我不知道如何让视图知道“setter”何时方法被调用。
有没有一种方法可以做到这一点,无需包装代理并将设置器委托给代理,同时引发事件?我希望该功能直接“插入”代理中。
I wish to achieve birectional binding of UI and data using Request Factory Proxies, and for that part I need a way to listen to the changes in a EntityProxy or a ValueProxy. If they were ordinary models, I could have attached my view to the model's change listener, but in request factory, the models or "proxies" are interfaces and I can't figure out, how to let the view know when a "setter" method is called.
Is there a way I can do this, without wrapping the proxy and delegating the setters to proxy, while at the same time raise events ? I want the functionality to be "plugged in" directly into the proxy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也对这个问题进行了思考和研究,但还没有抽出时间。
我认为您需要看一下 gwt MobileWebApp 示例。
他们有一个任务域对象,它有一个代理接口,但他们使用客户端接口的实现(请参阅TaskProxy & TaskProxyImpl)
我很想听听您是否愿意这方面取得了一些进展。
希望这有帮助
I also thought and researched abit on the matter, but haven't gotten around to it yet.
I think you need to take a look at the gwt MobileWebApp example.
They have a Task domain object, it has a proxy interface, but they use an implementation of the interface on the client side instead (see TaskProxy & TaskProxyImpl)
I would love to hear if you'll make some progress with this.
Hope this helps
我们实际上已经想出了一个解决方法。我们利用 GWT 生成器代码并在 autobean 代理中添加了一个
Listener
字段。之后,我们在每个生成的setter
方法中附加了一个listener.execute()
。现在我们可以将更改侦听器
附加到代理并侦听它们。唯一让我担心的是用于调用受保护方法并利用 GWT 生成器代码的 JSNI 调用。这有多好?
We have actually come up with a workaround. We tapped into the GWT generator code and added a
Listener
field in the autobean proxy. After that we appended alistener.execute()
in each of the generatedsetter
methods. So now we can attachchange listeners
to the proxy and listen to them.The only thing that worries me, is a
JSNI
call used to call a protected method and also tapping into the GWT generator code. How fine is this?