Search in sources :

Example 21 with WDataTable

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

the class WDataTableRenderer_Test method testDoPaintTableActionsWithConstraints.

@Test
public void testDoPaintTableActionsWithConstraints() throws IOException, SAXException, XpathException {
    final int minSelectedRowCount1 = 1;
    final int maxSelectedRowCount1 = 2;
    final String message1 = "message1";
    final int minSelectedRowCount2 = 1;
    final int maxSelectedRowCount2 = 2;
    final String message2 = "message2";
    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);
    WButton buttonOne = new WButton(TEST_ACTION_ONE);
    WButton buttonTwo = new WButton(TEST_ACTION_TWO);
    component.addAction(buttonOne);
    component.addAction(buttonTwo);
    component.addActionConstraint(buttonOne, new ActionConstraint(minSelectedRowCount1, maxSelectedRowCount1, true, message1));
    component.addActionConstraint(buttonTwo, new ActionConstraint(minSelectedRowCount2, maxSelectedRowCount2, false, message2));
    assertXpathExists("//ui:table/ui:actions", component);
    assertXpathEvaluatesTo(TEST_ACTION_ONE, "//ui:table/ui:actions/ui:action[1]/html:button", component);
    assertXpathEvaluatesTo(TEST_ACTION_TWO, "//ui:table/ui:actions/ui:action[2]/html:button", component);
    String expectedWarning = "error";
    assertXpathEvaluatesTo(((new Integer(minSelectedRowCount1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@minSelectedRows", component);
    assertXpathEvaluatesTo(((new Integer(maxSelectedRowCount1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@maxSelectedRows", component);
    assertXpathEvaluatesTo(expectedWarning, "//ui:table/ui:actions/ui:action[1]/ui:condition/@type", component);
    assertXpathEvaluatesTo(message1, "//ui:table/ui:actions/ui:action[1]/ui:condition/@message", component);
    expectedWarning = "warning";
    assertXpathEvaluatesTo(((new Integer(minSelectedRowCount2))).toString(), "//ui:table/ui:actions/ui:action[2]/ui:condition/@minSelectedRows", component);
    assertXpathEvaluatesTo(((new Integer(maxSelectedRowCount2))).toString(), "//ui:table/ui:actions/ui:action[2]/ui:condition/@maxSelectedRows", component);
    assertXpathEvaluatesTo(expectedWarning, "//ui:table/ui:actions/ui:action[2]/ui:condition/@type", component);
    assertXpathEvaluatesTo(message2, "//ui:table/ui:actions/ui:action[2]/ui:condition/@message", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) ActionConstraint(com.github.bordertech.wcomponents.WDataTable.ActionConstraint) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) ActionConstraint(com.github.bordertech.wcomponents.WDataTable.ActionConstraint) Test(org.junit.Test)

Example 22 with WDataTable

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

the class DataTableBeanExample method createTable.

/**
 * Creates and configures the table to be used by the example.
 *
 * @return a new configured table.
 */
private WDataTable createTable() {
    WDataTable tbl = new WDataTable();
    tbl.addColumn(new WTableColumn("First name", new WTextField()));
    tbl.addColumn(new WTableColumn("Last name", new WTextField()));
    tbl.addColumn(new WTableColumn("DOB", new WDateField()));
    return tbl;
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) WDateField(com.github.bordertech.wcomponents.WDateField) WTextField(com.github.bordertech.wcomponents.WTextField)

Example 23 with WDataTable

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

the class DataTableOptionsExample method createBasicDataTable.

/**
 * @return a basic table example.
 */
private WDataTable createBasicDataTable() {
    WDataTable table = new WDataTable();
    table.setType(WDataTable.Type.TABLE);
    table.addColumn(new WTableColumn("Column1", WText.class));
    table.addColumn(new WTableColumn("Column2", WText.class));
    table.addColumn(new WTableColumn("Column3", WText.class));
    table.setRowsPerPage(DEFAULT_ROWS_PER_PAGE);
    table.setSummary("Basic table summary");
    table.setCaption("Basic table caption");
    ExampleDataModel data = new ExampleDataModel();
    data.setData(createData());
    table.setDataModel(data);
    return table;
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WText(com.github.bordertech.wcomponents.WText) WDataTable(com.github.bordertech.wcomponents.WDataTable)

Example 24 with WDataTable

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

the class ScrollableDataTableModelExample method createTable.

/**
 * Creates and configures the table to be used by the example. The table is configured with global rather than user
 * data. Although this is not a realistic scenario, it will suffice for this example.
 *
 * @return a new configured table.
 */
private WDataTable createTable() {
    WDataTable table = new WDataTable();
    table.addColumn(new WTableColumn("First name", WText.class));
    table.addColumn(new WTableColumn("Last name", WText.class));
    table.addColumn(new WTableColumn("DOB", WText.class));
    table.setPaginationMode(PaginationMode.DYNAMIC);
    table.setRowsPerPage(1);
    table.setDataModel(createTableModel());
    return table;
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WText(com.github.bordertech.wcomponents.WText) WDataTable(com.github.bordertech.wcomponents.WDataTable)

Example 25 with WDataTable

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

the class SelectableDataTableExample method createTable.

/**
 * Creates and configures the table to be used by the example. The table is configured with global rather than user
 * data. Although this is not a realistic scenario, it will suffice for this example.
 *
 * @return a new configured table.
 */
private WDataTable createTable() {
    WDataTable table = new WDataTable();
    table.addColumn(new WTableColumn("First name", new WText()));
    table.addColumn(new WTableColumn("Last name", new WText()));
    table.addColumn(new WTableColumn("DOB", new WText()));
    String[][] data = new String[][] { new String[] { "Joe", "Bloggs", "01/02/1973" }, new String[] { "Jane", "Bloggs", "04/05/1976" }, new String[] { "Kid", "Bloggs", "31/12/1999" } };
    table.setDataModel(new SimpleTableDataModel(data));
    return table;
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WText(com.github.bordertech.wcomponents.WText) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel)

Aggregations

WDataTable (com.github.bordertech.wcomponents.WDataTable)41 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)38 WTextField (com.github.bordertech.wcomponents.WTextField)29 Test (org.junit.Test)28 SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)23 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)23 WText (com.github.bordertech.wcomponents.WText)8 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)5 WButton (com.github.bordertech.wcomponents.WButton)5 ActionConstraint (com.github.bordertech.wcomponents.WDataTable.ActionConstraint)4 WDateField (com.github.bordertech.wcomponents.WDateField)4 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)3 UIContext (com.github.bordertech.wcomponents.UIContext)2 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WDataTableRowRenderer (com.github.bordertech.wcomponents.WDataTableRowRenderer)1 WRepeater (com.github.bordertech.wcomponents.WRepeater)1 SubUIContext (com.github.bordertech.wcomponents.WRepeater.SubUIContext)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 TreeNode (com.github.bordertech.wcomponents.util.TreeNode)1