开发者

GWT Activity and Editor Framework

I´ve been working on some small projects using GWT MVP framework + GWT Editors framework. I have Views interfaces with fields declared like:

 @Path("field")
 IsEditor<ValueBoxEditor<Long>> getField();

Views implementations look like this:

@UiField
   IsEditor<ValueBoxEditor<Long>> field;
public IsEditor<ValueBoxEditor<Long>> getField(){
   return field;
}

In my Activitys I have referances to correspond Views and when I have to do(in Activity) something like this:

view.getField.setEnable(true);

I have to do cast to

((ValueBoxBase<Long>)view.getField()).setEnable(true);

After that I can't test this unit, because in my test I define behaviour of View to return Mock (IsEditor<ValueBoxEditor<Long>>) on view.getFiled() as result I get:

java.lang.ClassCastException: com.google.gwt.editor.client.IsEditor$
$EnhancerByMockitoWithCGLIB$$e8c00c36 cannot开发者_开发问答 be cast to
com.google.gwt.user.client.ui.ValueBoxBase

What is best practiece to call Views components methods from Activity without doing casting?


Cast to HasEnabled instead of ValueBoxBase.


You need to use the ValueBoxEditor adapter method "of":

@UiField ValueBoxBase<Long> field;

public ValueBoxEditor<Long> getField(){
   return ValueBoxEditor.of(field);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜