GWT/MVP:使用适当的 MVP 模式检测表中的更改事件
我们正在使用 gwt-presenter,但实际上并不是一个特定的问题......
我有一个包含用户的表。当我在视图中构建表格(根据演示者提供的数据)时,我需要在行末尾添加两个操作按钮(“编辑”和“删除”)。
将单击处理程序分配给这些按钮以便演示者知道单击了哪个按钮的最佳方法是什么?在此之前,我们可以将私有字段从视图传递给演示者,并将离散的单击处理程序附加到该按钮。然而,这种方法相当僵化,在这种情况下效果不太好。
提前致谢。
We're using gwt-presenter, but not really a question specific to that...
I've got a table with users in it. As I build the table in the view (from the data provided by the presenter), I need to add two action buttons ("Edit", and "Delete") at the end of the row.
What's the best way to assign click handlers to these buttons so the presenter knows which was clicked? Previous to this, we could pass a private field from the view to the presenter and attach a discrete click handler to that button. However, this method is rather rigid and doesn't work in this scenario very well.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让视图允许订阅编辑/删除单击事件,在内部注册各个行单击事件,然后将事件处理委托给视图注册的事件怎么样?
我的意思是类似以下伪代码:
View:
Presenter:
How about having the view allowing the subscription for edit/delete click events, registering internally the individual row click events, and then delegating the event handling to the ones registered by the view?
I mean something like the following pesudo code:
View:
Presenter: