2012-08-15 3 views
1

안녕하세요 저는 GWT를 처음 접했고 GWTP도 처음이에요.GWTP : CellTable을 표시하는 데 문제가 있습니다.

나는 CellTables와 재생하려고하고 내가 GWTP MVP에 맞게 몇 가지 적응 developers.google.com/web-toolkit/doc/2.4/DevGuideUiCellWidgets#celltable 에서 GWT 문서 다음과 같은 간단한 하나를 구축하여 시작하기로 결정 디자인.

첫째, 내 View.ui.xml 파일 내 Celltable을 만들어 내 View.java 파일에

public class Contact { 
    private final String address; 
    private final String name; 

    public Contact(String name, String address) { 
     this.name = name; 
     this.address = address; 
    } 

    public String getAddress() { 
     return address; 
    } 

    public String getName() { 
     return name; 
    } 
} 

:

다음

xmlns:c="urn:import:com.google.gwt.user.cellview.client"> 
<g:HTMLPanel> 
    <c:CellTable pageSize='15' ui:field='cellTable' /> 
</g:HTMLPanel> 

을, 나는 클래스 연락을 생성

@UiField(provided=true) CellTable<Contact> cellTable = new CellTable<Contact>(); 

public CellTable<Contact> getCellTable() { 
    return cellTable; 
} 

마지막으로 내 Presenter.java 파일에서 :

당신의 도움에 미리 ...

덕분에3210

public interface MyView extends View { 
    CellTable<Contact> getCellTable(); 
} 

@Override 
protected void onReset() { 
    super.onReset(); 

    // Create name column. 
    TextColumn<Contact> nameColumn = new TextColumn<Contact>() { 
      @Override 
      public String getValue(Contact contact) { 
      return contact.getName(); 
      } 
     }; 

    // Create address column. 
    TextColumn<Contact> addressColumn = new TextColumn<Contact>() { 
      @Override 
      public String getValue(Contact contact) { 
      return contact.getAddress(); 
      } 
     }; 

    // Add the columns. 
    getView().getCellTable().addColumn(nameColumn, "Name"); 
    getView().getCellTable().addColumn(addressColumn, "Address"); 

    // Set the total row count. 
    getView().getCellTable().setRowCount(CONTACTS.size(), true); 

    // Push the data into the widget. 
    getView().getCellTable().setRowData(0, CONTACTS); 
} 

모든 것은 나에게 좋은 것 같습니다하지만이 코드를 시도 할 때 표시되지 CellTable가 없습니다 ... 그리고 나는 오류를 얻을!

답변

0

CellTable에 DataProvider가 등록되어 있지 않은 것 같습니다. GWT CellWidgets은 DataProvider/DIsplay 패턴을 기반으로합니다. 그래서 CellTable은 DataProvider의 디스플레이 일뿐입니다. 하나의 DataProvider는 여러 개의 디스플레이를 가질 수 있습니다.

당신은 쓸 필요가 없습니다

// Set the total row count. 
getView().getCellTable().setRowCount(CONTACTS.size(), true); 

// Push the data into the widget. 
getView().getCellTable().setRowData(0, CONTACTS); 

당신은 당신이 새 데이터로 DataProvider를 업데이트 할 때 DataProvider를 (예를 들어 ListDataProvider) 및 전화 새로 고침 방법보다 디스플레이로 CellTable을 등록해야합니다.

관련 문제