GWT 活动和编辑器框架
我一直在使用 GWT MVP 框架 + GWT 从事一些小项目 编辑器框架。我有视图接口,其字段声明如下:
@Path("field")
IsEditor<ValueBoxEditor<Long>> getField();
视图实现如下所示:
@UiField
IsEditor<ValueBoxEditor<Long>> field;
public IsEditor<ValueBoxEditor<Long>> getField(){
return field;
}
在我的活动中,我有对应视图的引用,当我有 做(在 Activity 中)类似这样的事情:
view.getField.setEnable(true);
我必须强制转换为
((ValueBoxBase<Long>)view.getField()).setEnable(true);
After 之后我无法测试这个单元,因为在我的测试中我定义了 View 的行为以返回 Mock (IsEditor
on view.getFiled()
结果我得到:
java.lang.ClassCastException: com.google.gwt.editor.client.IsEditor$
$EnhancerByMockitoWithCGLIB$$e8c00c36 cannot be cast to
com.google.gwt.user.client.ui.ValueBoxBase
What is bestpractiece to call Views Componentsmethods from Activity 不做铸造?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
转换为 HasEnabled 而不是 ValueBoxBase。
Cast to HasEnabled instead of ValueBoxBase.
您需要使用 ValueBoxEditor 适配器方法“of”:
You need to use the ValueBoxEditor adapter method "of":