Search in sources :

Example 26 with WTableColumn

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

the class WDataTableRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WDataTable table = new WDataTable();
    table.addColumn(new WTableColumn(getMaliciousContent(), WText.class));
    table.addColumn(new WTableColumn(getMaliciousContent(), WText.class));
    table.addColumn(new WTableColumn(getMaliciousContent(), WText.class));
    table.setNoDataMessage(getMaliciousAttribute("ui:table"));
    UIContext uic = createUIContext();
    assertSafeContent(table);
    WButton button = new WButton("dummy");
    table.addAction(button);
    table.addActionConstraint(button, new ActionConstraint(0, 1, false, getMaliciousAttribute("ui:action")));
    assertSafeContent(table);
    TableDataModel tableModel = createTableModel();
    table.setDataModel(tableModel);
    // clear out cached data from previous renders
    uic.clearScratchMap();
    assertSafeContent(table);
    table.setCaption(getMaliciousAttribute("ui:table"));
    assertSafeContent(table);
    table.setSummary(getMaliciousAttribute("ui:table"));
    assertSafeContent(table);
    table.setSelectGroup(getMaliciousAttribute("ui:rowselection"));
    assertSafeContent(table);
    table.setActiveFilters(Arrays.asList(new String[] { getMaliciousAttribute("ui:table") }));
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) 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) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 27 with WTableColumn

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

the class WDataTableRenderer_Test method testDoPaintMissingAttributesColumnStriping.

@Test
public void testDoPaintMissingAttributesColumnStriping() 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));
    component.setDataModel(createTableModel());
    component.setVisible(true);
    component.setStripingType(WDataTable.StripingType.COLUMNS);
    component.setSeparatorType(WDataTable.SeparatorType.VERTICAL);
    assertXpathNotExists("//ui:table/@caption", component);
    assertXpathEvaluatesTo("table", "//ui:table/@type", component);
    assertXpathEvaluatesTo("cols", "//ui:table/@striping", component);
    assertXpathEvaluatesTo("vertical", "//ui:table/@separators", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 28 with WTableColumn

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

the class WDataTableRenderer_Test method testDoPaintSortableSortModeDynamic.

@Test
public void testDoPaintSortableSortModeDynamic() 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 = createTableModelSortable();
    component.setDataModel(tableModel);
    component.setVisible(true);
    // sortMode dynamic
    component.setSortMode(SortMode.DYNAMIC);
    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 29 with WTableColumn

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

the class WDataTableRenderer_Test method testDoPaintWithColAlignment.

@Test
public void testDoPaintWithColAlignment() throws IOException, SAXException, XpathException {
    WDataTable table = new WDataTable();
    table.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
    table.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
    table.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
    table.getColumn(0).setAlign(WTableColumn.Alignment.LEFT);
    table.getColumn(1).setAlign(WTableColumn.Alignment.CENTER);
    table.getColumn(2).setAlign(WTableColumn.Alignment.RIGHT);
    TableDataModel tableModel = createTableModel();
    table.setDataModel(tableModel);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[1]/@align", table);
    assertXpathEvaluatesTo("center", "//ui:table/ui:thead/ui:th[2]/@align", table);
    assertXpathEvaluatesTo("right", "//ui:table/ui:thead/ui:th[3]/@align", table);
}
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 30 with WTableColumn

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

the class WDataTableRenderer_Test method testDoPaintEmptyTableNoAttributes.

@Test
public void testDoPaintEmptyTableNoAttributes() 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));
    component.setVisible(true);
    setActiveContext(createUIContext());
    assertXpathEvaluatesTo(component.getNoDataMessage(), "//ui:table/ui:tbody/ui:nodata", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

WTableColumn (com.github.bordertech.wcomponents.WTableColumn)73 WTextField (com.github.bordertech.wcomponents.WTextField)60 Test (org.junit.Test)56 WDataTable (com.github.bordertech.wcomponents.WDataTable)38 WTable (com.github.bordertech.wcomponents.WTable)30 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)25 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)24 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)23 SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)23 SimpleTableModel (com.github.bordertech.wcomponents.SimpleTableModel)23 WText (com.github.bordertech.wcomponents.WText)9 WButton (com.github.bordertech.wcomponents.WButton)8 WDateField (com.github.bordertech.wcomponents.WDateField)7 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)5 ActionConstraint (com.github.bordertech.wcomponents.WDataTable.ActionConstraint)4 ActionConstraint (com.github.bordertech.wcomponents.WTable.ActionConstraint)4 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)4 UIContext (com.github.bordertech.wcomponents.UIContext)3 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)2 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)2