2016-01-20 35 views
0

我試圖使用GWTBootstrap和我收到以下錯誤,當運行項目:GWTBootstrap:類型不匹配:不能轉換從org.gwtbootstrap3.client.ui.Button到com.google.gwt.user.client.ui.Button

Type mismatch: cannot convert from org.gwtbootstrap3.client.ui.Button to com.google.gwt.user.client.ui.Button 

我ui.xml看起來是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> 
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' 
    xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:b="urn:import:org.gwtbootstrap3.client.ui"> 

    <ui:with field='res' type='resources.MyResources' /> 

    <b:Container fluid="true"> 
     <b:Row> 
      <b:Column size="MD_1"> 
       <g:HTMLPanel addStyleNames="{res.loginCss.maindiv}"> 
        <g:VerticalPanel addStyleNames="{res.loginCss.form}"> 
         <g:HorizontalPanel addStyleNames="{res.loginCss.formPart}"> 
          <g:TextBox ui:field="matrnrTextBox" addStyleNames="{res.loginCss.nameTextBox}" /> 
         </g:HorizontalPanel> 
         <g:HorizontalPanel addStyleNames="{res.loginCss.formPart}"> 
          <g:PasswordTextBox ui:field="passwordTextBox" 
           addStyleNames="{res.loginCss.passwordTextBox}" /> 
         </g:HorizontalPanel> 
         <b:Button text="Block level button" block="true" ui:field="loginButton" /> 
               <!-- <g:Button text="Login" /> --> <!-- ui:field="loginButton" addStyleNames="{res.loginCss.loginButton}" --> 
        </g:VerticalPanel> 
       </g:HTMLPanel> 
      </b:Column> 
     </b:Row> 
    </b:Container> 
</ui:UiBinder> 

它是這樣工作的,但是當我添加ui:field屬性的b:Button元素,我得到上述錯誤。從我的Java類按鈕:

我怎樣才能訪問的B?我必須使用按鈕的ID直接通過DOM來完成嗎?在你的java文件中的字段像com.google.gwt.user.client.ui.Button:

我使用這個版本GWTBootstrap的:

 <groupId>org.gwtbootstrap3</groupId> 
     <artifactId>gwtbootstrap3</artifactId> 
     <version>0.9.2</version> 
+1

的按鈕類是你在你的視圖類引用? –

回答

3

你引用你的用戶界面。

@UiField 
com.google.gwt.user.client.ui.Button loginButton; 

應該

@UiField 
org.gwtbootstrap3.client.ui.Button loginButton; 

相反。檢查導入部分

相關問題