我想在我的项目中使用 GWT 的编辑器框架。
在我的 View (实现编辑器)中,我有我的 UiBinder 字段:
@UiField
TextBox text;
在我的 Presenter 中,我通过 GIN 注入(inject)驱动程序实例:
@Inject
public AppointmentPopupPresenter(EventBus eventBus, MyView view, final AppointmentDriver appointmentDriver)
当演示者被调用时,我尝试使用以下方法初始化驱动程序:
this.appointmentDriver.initialize(getView());
this.appointmentDriver.edit(new Appointment());
GIN 模块:
bind(SimpleBeanEditorDriver.class).to(AppointmentDriver.class);
AppointmentDriver 接口(interface):
public interface AppointmentDriver extends SimpleBeanEditorDriver<Appointment, AppointmentPopupPresenter.MyView>{
}
稍后,当我监听按钮事件时,我调用:
appointmentDriver.flush();
但所有属性均为 null,并且不会抛出任何错误消息。如果我查看调试器中的文本框小部件,“编辑器”的实例也为空。不知道内部,但也许这对你来说是一个提示。
约会 POJO(当然使用 void setText(String text)/String getText()):
String text;
目前我完全陷入困境,因此非常欢迎任何帮助。
谢谢!!
最佳答案
我看到你做了一个 getView()
,它返回的 View 是否与传递给构造函数的 View 相同,并且与 ui 中显示的 View 相同?驱动程序可能使用与实际显示的 View 不同的 View 进行初始化,因此您将从错误的 View 中获取数据。我也不明白你为什么要进行绑定(bind),似乎没有必要?
关于gwt - 编辑器字段未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6905117/