1

ページのボタンをクリックすると、非常に単純な cellTable を表示しようとしています。ただし、セルテーブルはレンダリングされません。

理解を深めるために、以下のコード スニペットを提供します。

preview.ui.xml ファイル

<g:HTMLPanel>
    <div class="{bundle.css.roundedBorder}">
        <table style='width:100%;'>
            <tr>
                <td>
                    <c:CellTable pageSize='15' ui:field='cellTable' width="100%">  
                    </c:CellTable> 
                </td>
            </tr>
        </table>
    </div>
</g:HTMLPanel>

対応する Java クラス:

public class Preview extends Composite {
.
.
.   // other generic GWT code to bind UIBinder XML with this class
.
.
.

@UiField
CellTable<Contact> cellTable;

@UiHandler("button")
void handleClickOnSearchButton(ClickEvent e) {
    cellTable = configureCellTable();
}

private CellTable<Contact> configureCellTable() {
// The list of data to display.
  List<Contact> CONTACTS = Arrays.asList(new Contact("John", "123 Fourth Road"), new Contact("Mary", "222 Lancer Lane"), new Contact("Zander", "94 Road Street"));
// Create a CellTable.
  CellTable<Contact> table = new CellTable<Contact>();


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




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

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


    // Create a data provider.
    ListDataProvider<Contact> dataProvider = new ListDataProvider<Contact>();

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

 // Add the data to the data provider, which automatically pushes it to the widget.
    List<Contact> list = dataProvider.getList();
    for (Contact contact : CONTACTS) {
      list.add(contact);
    }


return table;
}



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

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

ガイドしてください!

ありがとう、

アクシャイ

4

1 に答える 1