Search in sources :

Example 71 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintAttributesAndContent.

@Test
public void testDoPaintAttributesAndContent() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    // renderer class
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    // renderer instance
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, new WTextField()));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setSummary(TABLE_SUMMARY_TEST);
    component.setCaption(CAPTION_TEST);
    component.setType(WDataTable.Type.HIERARCHIC);
    setActiveContext(createUIContext());
    // check ui:table attributes
    String tableId = component.getId();
    assertXpathEvaluatesTo(tableId, "//ui:table/@id", component);
    assertXpathEvaluatesTo(CAPTION_TEST, "//ui:table/@caption", component);
    assertXpathEvaluatesTo("hierarchic", "//ui:table/@type", component);
    // check header values
    String[] colHeaders = { COL1_HEADING_TEST, COL2_HEADING_TEST, COL3_HEADING_TEST };
    for (int i = 0; i < component.getColumnCount(); i++) {
        assertXpathEvaluatesTo(colHeaders[i], "//ui:table/ui:thead/ui:th[" + (i + 1) + "]/ui:decoratedlabel/ui:labelbody", component);
    }
    // check table content
    for (int i = 0; i < tableModel.getRowCount(); i++) {
        for (int j = 0; j < component.getColumnCount(); j++) {
            assertXpathEvaluatesTo((String) tableModel.getValueAt(i, j), "//ui:table/ui:tbody/ui:tr[" + (i + 1) + "]/ui:td[" + (j + 1) + "]/ui:textfield", component);
        }
    }
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) ActionConstraint(com.github.bordertech.wcomponents.WDataTable.ActionConstraint) Test(org.junit.Test)

Example 72 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintSortableSortModeServer.

// SERVER outputs "dynamic" see https://github.com/BorderTech/wcomponents/issues/701
@Test
public void testDoPaintSortableSortModeServer() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    // sortable data model
    TableDataModel tableModel = createTableModelSortable();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setSortMode(SortMode.SERVER);
    assertXpathEvaluatesTo("dynamic", "//ui:table/ui:sort/@mode", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[1]/@sortable", component);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[2]/@sortable", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[3]/@sortable", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 73 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintPaginatedServer.

@Test
public void testDoPaintPaginatedServer() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setPaginationMode(PaginationMode.DYNAMIC);
    setActiveContext(createUIContext());
    assertXpathEvaluatesTo("dynamic", "//ui:table/ui:pagination/@mode", component);
    assertXpathEvaluatesTo((new Integer(component.getCurrentPage())).toString(), "//ui:table/ui:pagination/@currentPage", component);
    assertXpathEvaluatesTo((new Integer(component.getRowsPerPage())).toString(), "//ui:table/ui:pagination/@rowsPerPage", component);
    assertXpathEvaluatesTo((new Integer(tableModel.getRowCount())).toString(), "//ui:table/ui:pagination/@rows", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 74 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class TableLoadPerformance method setupWDataTable.

/**
 * Setup WTable.
 */
private void setupWDataTable() {
    WTextField col1 = new WTextField();
    col1.setIdName("my1");
    col1.setReadOnly(true);
    WTextField col2 = new WTextField();
    col2.setIdName("my2");
    col2.setReadOnly(true);
    WDateField col3 = new WDateField();
    col3.setIdName("my3");
    col3.setReadOnly(true);
    datatable.addColumn(new WTableColumn("COL1", col1));
    datatable.addColumn(new WTableColumn("COL2", col2));
    datatable.addColumn(new WTableColumn("COL3", col3));
    datatable.setExpandMode(WDataTable.ExpandMode.CLIENT);
    datatable.setIdName("wdt");
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDateField(com.github.bordertech.wcomponents.WDateField) WTextField(com.github.bordertech.wcomponents.WTextField)

Example 75 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class TableLoadPerformance method setupWTable.

/**
 * Setup WTable.
 */
private void setupWTable() {
    WTextField col1 = new WTextField();
    col1.setIdName("my1");
    col1.setReadOnly(true);
    WTextField col2 = new WTextField();
    col2.setIdName("my2");
    col2.setReadOnly(true);
    WDateField col3 = new WDateField();
    col3.setIdName("my3");
    col3.setReadOnly(true);
    table.addColumn(new WTableColumn("COL1", col1));
    table.addColumn(new WTableColumn("COL2", col2));
    table.addColumn(new WTableColumn("COL3", col3));
    table.setExpandMode(WTable.ExpandMode.CLIENT);
    table.setIdName("wt");
    LevelDetails level = new LevelDetails("documents", TravelDocPanel.class, true);
    SimpleBeanBoundTableModel model = new SimpleBeanBoundTableModel(new String[] { "firstName", "lastName", "dateOfBirth" }, level);
    table.setTableModel(model);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) SimpleBeanBoundTableModel(com.github.bordertech.wcomponents.SimpleBeanBoundTableModel) WDateField(com.github.bordertech.wcomponents.WDateField) WTextField(com.github.bordertech.wcomponents.WTextField) LevelDetails(com.github.bordertech.wcomponents.SimpleBeanBoundTableModel.LevelDetails)

Aggregations

WTableColumn (com.github.bordertech.wcomponents.WTableColumn)76 WTextField (com.github.bordertech.wcomponents.WTextField)62 Test (org.junit.Test)57 WDataTable (com.github.bordertech.wcomponents.WDataTable)38 WTable (com.github.bordertech.wcomponents.WTable)32 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)27 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)24 SimpleTableModel (com.github.bordertech.wcomponents.SimpleTableModel)24 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)24 SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)23 WText (com.github.bordertech.wcomponents.WText)11 WButton (com.github.bordertech.wcomponents.WButton)8 WDateField (com.github.bordertech.wcomponents.WDateField)7 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)5 ActionConstraint (com.github.bordertech.wcomponents.WDataTable.ActionConstraint)4 ActionConstraint (com.github.bordertech.wcomponents.WTable.ActionConstraint)4 UIContext (com.github.bordertech.wcomponents.UIContext)3 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)2 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)2