2012-07-11 1 views
0

Je suis en train de créer mon extension personnalisée TabLayoutPanel, mon code est le suivant:sur mesure TabLayoutPanel dans GWT

public class ExpandableTabLayoutPanel extends TabLayoutPanel { 

    @UiConstructor 
    public ExpandableTabLayoutPanel(double barHeight, Unit barUnit) { 
     super(barHeight, barUnit); 
     addExpandableBehaviour(); 
    } 

    private addExpandableBehaviour(){ 
     //... 
    } 
} 

Et là, je l'invoquons de UIBinder:

<a:ExpandableTabLayoutPanel barHeight="20" barUnit="PX"> 
    <a:tab> 
    <a:header>header</a:header> 
     <a:AdvancedRichTextArea styleName="{style.area}" ui:field="area"/> 
    </a:tab> 
</a:ExpandableTabLayoutPanel> 

(j'ai été forcé par messages d'erreur à utiliser a:tab/a:header au lieu de g:tab/g:header même si je n'ai pas d'onglet et d'en-tête définis dans mon package/workspace a:, mais ce n'est probablement pas le problème)

Si l'annotation @UiConstructor est présent sur ExpandableTabLayoutPanel comme dans la liste, je reçois une erreur étrange:

[ERROR] [gwtreproduce] - <a:ExpandableTabLayoutPanel barHeight='20' barUnit='PX'> missing required attribute(s): arg1 barHeight Element <a:ExpandableTabLayoutPanel barHeight='20' barUnit='PX'> (:13) 

Quand je désactiver @UiConstructor, je me fais erreur encore plus étrange:

[ERROR] [gwtreproduce] - Errors in 'generated://E6338B946DFB2D28988DA492134093C7/reproduce/client/TestView_TestViewUiBinderImpl.java' :    [ERROR] [gwtreproduce] - Line 33: Type mismatch: cannot convert from TabLayoutPanel to ExpandableTabLayoutPanel 

Qu'est-ce que je fais de mal à étendre TabLayoutPanel?

Et question subsidiaire: comment il est possible que le constructeur TabLayoutPanel ne soit pas annoté avec @UiConstructor et puisse être utilisé dans UiBinder (comment UiBinder sait-il quel constructeur appeler)?

+0

double possible de [ui.xml GWT; impossible de convertir le panneau docklayout en panneau personnalisé] (http://stackoverflow.com/questions/11433805/gwt-ui-xml-cannot-convert-docklayout-panel-to-custom-panel) –

Répondre

0

pour vous question: vous devez ajouter (fourni = vrai) à l'annotation UiField de votre widget. Ensuite, dans le code, définissez l'instance vous, avant createAndBindUi() appeler comme ceci:

class Whaoo extends Composite{ 

    /* with 'provided', UiBinder don't call any constructor */ 
    @UiField(provided = true) 
    final Great foo; 

    interface WhaooUiBinder extends 
     UiBinder<Widget, Whaoo> {} 

    private static WhaooUiBinder uiBinder = 
     GWT.create(WhaooUiBinder.class); 

    public Whaoo() { 

     // initialize "provided" before createAndBindUi call 
     foo = new Great(String bar, int pouet); 

     initWidget(uiBinder.createAndBindUi(this)); 

    } 
} 
Questions connexes