2011-04-15 3 views
2

J'ai travaillé sur de petits projets en utilisant GWT MVP framework + GWT Framework des éditeurs. J'ai Vues interfaces avec des champs déclarés comme:GWT Activity and Editor Framework

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

Vues implémentations ressemblent à ceci:

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

Dans mes Activitys j'ai referances pour correspondre les vues et quand j'ai à faire (en activité) quelque chose comme ceci:

view.getField.setEnable(true); 

que je dois faire cAST pour

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

Après que je ne peux pas tester cet appareil, car dans mon test, je définir le comportement de vue pour revenir Mock (IsEditor<ValueBoxEditor<Long>>) sur view.getFiled() comme résultat je reçois:

java.lang.ClassCastException: com.google.gwt.editor.client.IsEditor$ 
$EnhancerByMockitoWithCGLIB$$e8c00c36 cannot be cast to 
com.google.gwt.user.client.ui.ValueBoxBase 

Quelle est la meilleure practiece appeler Vues méthodes composants de l'activité sans faire de casting?

Répondre

0

Cast à HasEnabled au lieu de ValueBoxBase.

+0

asdjava.lang.ClassCastException: com.google.gwt.editor.client.IsEditor $$ $$ EnhancerByMockitoWithCGLIB ea68060b ne peut pas être jeté à com .google.gwt.user.client.ui.HasEnabled – user709433

+0

Ça ne va pas aider avec mon test, j'ai toujours java.lang.ClassCastException: com.google.gwt.editor.client.IsEditor $$ EnhancerByMockitoWithCGLIB $$ ea68060b ne peut pas être converti en com.google.gwt.user.client.ui.HasEnabled Je veux trouver une approche pour obtenir un widget à partir d'un objet sous IsEditor > dans Activité sans forte conversion. – user709433

0

Vous devez utiliser la méthode d'adaptation ValueBoxEditor "de":

@UiField ValueBoxBase<Long> field; 

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