use of com.github.bordertech.wcomponents.WTable in project wcomponents by BorderTech.
the class WTableOptionsExample method createExpandedDataTable.
/**
* @return a table that has expanded content.
*/
private WTable createExpandedDataTable() {
WTable table = new WTable();
addColumns(table);
table.setType(WTable.Type.TABLE);
table.setRowsPerPage(DEFAULT_ROWS_PER_PAGE);
table.setCaption("Expanded content table caption");
table.setBeanProperty(".");
// Define the expandable level. The row will expand if the bean has "extra" details
LevelDetails level1 = new LevelDetails("documents", TravelDocPanel.class);
// Setup model with column properties and the "expandable" level
MyBeanBoundTableModel model = new MyBeanBoundTableModel(new String[] { "firstName", "lastName", "dateOfBirth" }, level1);
model.setSelectable(true);
model.setEditable(true);
model.setComparator(0, SimpleBeanBoundTableModel.COMPARABLE_COMPARATOR);
model.setComparator(1, SimpleBeanBoundTableModel.COMPARABLE_COMPARATOR);
table.setTableModel(model);
return table;
}
use of com.github.bordertech.wcomponents.WTable in project wcomponents by BorderTech.
the class TableUtil method getCurrentRowIndex.
/**
* This can be used by column components on a {@link WTable} to determine the current row index.
*
* @param component the column component
* @return the row index for the current row, or null if no row details
*/
public static List<Integer> getCurrentRowIndex(final WComponent component) {
UIContext uic = UIContextHolder.getCurrent();
// Check have correct context
if (!(uic instanceof SubUIContext)) {
return null;
}
// Find the table
WTable table = WebUtilities.getAncestorOfClass(WTable.class, component);
if (table == null) {
return null;
}
int repeaterIdx = ((SubUIContext) uic).getRowIndex();
RowIdWrapper wrapper = table.getRepeater().getBeanList().get(repeaterIdx);
return wrapper.getRowIndex();
}
use of com.github.bordertech.wcomponents.WTable in project wcomponents by BorderTech.
the class WTableRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WTable component = new WTable();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WTableRenderer);
}
use of com.github.bordertech.wcomponents.WTable in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintPaginatedDynamic.
@Test
public void testDoPaintPaginatedDynamic() throws IOException, SAXException, XpathException {
WTable component = new WTable();
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));
TableModel tableModel = createTableModel();
component.setTableModel(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);
}
use of com.github.bordertech.wcomponents.WTable in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintSelectModeMultipleSelectAllControl.
@Test
public void testDoPaintSelectModeMultipleSelectAllControl() throws IOException, SAXException, XpathException {
WTable component = new WTable();
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));
TableModel tableModel = createTableModel();
component.setTableModel(tableModel);
component.setVisible(true);
component.setSelectMode(WTable.SelectMode.MULTIPLE);
component.setSelectAllMode(WTable.SelectAllType.CONTROL);
assertXpathExists("//ui:table/ui:rowselection", component);
assertXpathEvaluatesTo(TRUE, "//ui:table/ui:rowselection/@multiple", component);
assertXpathEvaluatesTo("control", "//ui:table/ui:rowselection/@selectAll", component);
// toggle not available by default
assertXpathNotExists("//ui:table/ui:rowselection/@toggle", component);
}
Aggregations