how to add a static value to a FlexTable in the ui.xml file GWT?

49 Views Asked by At

I'm making a widget in an application using the GWT framework. it is a table of 13 columns and 3 rows. The first line is the names of the months. The first column is the names of the lines - income and expense. The remaining data is filled in from the service.

Now the first column is filled with the setRowNames() method. you need to make sure that these names are filled in the ui.xml file.

public class FinancialWidget extends Composite {
    /**
     * 
     */


    FlexTable flexTable;

  /**
     * 
     */
    


    private void setRowsNames() {
        flexTable.setText(0, 0, "Month");
        flexTable.setText(1, 0, "income");
        flexTable.setText(2, 0, "expence");
    }

}
<gwt:HTMLPanel>
    <gwt:FlexTable ui:field="financialFlexTable"/>
</gwt:HTMLPanel>

I tried to implement it like this

        <gwt:FlexTable ui:field="financialFlexTable">
            <tr>
                <td>month</td>
            </tr>
            <tr>
                <td>income</td>
            </tr>
            <tr>
                <td>expence</td>
            </tr>
        </gwt:FlexTable>

-- compilation error

        <gwt:FlexTable ui:field="financialFlexTable">
            <gwt:row>
                <gwt:cell>month</gwt:cell>
            </gwt:row>
            <gwt:row>
                <gwt:cell>income</gwt:cell>
            </gwt:row>
            <gwt:row>
                <gwt:cell>expence</gwt:cell>
            </gwt:row>
        </gwt:FlexTable>

gwt:row, gwt:cell - does not exist

1

There are 1 best solutions below

0
collder On

Your question is not clear enough. ui.xml file is not usual html file. You cannot generate table both from code and with basic html tags.

First of all - did you read the docs with examples?

The way that I use FlexTable in project is to table.setWidget().

int row = table.getRowCount(); // get the last row
Label name = new Label("Column 1 value");
table.setWidget(row, 0, name);
Label valueLb = new Label("Column 2 value");
table.setWidget(row, 1, valueLb);

Maybe you need to use DataGrid if your table is rendering from one object type. In some ways it's more convenient.