use of com.github.bordertech.wcomponents.SimpleBeanBoundTableModel.LevelDetails 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);
}
use of com.github.bordertech.wcomponents.SimpleBeanBoundTableModel.LevelDetails 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.SimpleBeanBoundTableModel.LevelDetails in project wcomponents by BorderTech.
the class UIContextImpl_Test method testFocusableInWTableNestedBeanBound.
@Test
public void testFocusableInWTableNestedBeanBound() {
// Beans list
final MyBean option1 = new MyBean();
final MyBean option2 = new MyBean();
final List<MyBean> beans = Arrays.asList(new MyBean[] { option1, option2 });
// Another beans list for nested repeater
final String optionA = "A";
final String optionB = "B";
final String optionC = "C";
final String optionD = "D";
final List<String> beans2 = Arrays.asList(new String[] { optionA, optionB, optionC, optionD });
// Add beans to Option1 for nested repeater
option1.setRows(beans2);
// Setup the table with an expandable level
WTable table = new WTable();
LevelDetails lvl = new LevelDetails("rows", MyTable.class, false);
table.setTableModel(new SimpleBeanBoundTableModel(new String[] { "." }, lvl));
table.addColumn(new WTableColumn("test", new WText()));
table.setExpandMode(ExpandMode.CLIENT);
table.setBeanProperty(".");
// Lock component
table.setLocked(true);
// Set the table as the "UI" for context
UIContext uic = new UIContextImpl();
uic.setUI(table);
setActiveContext(uic);
// Setup the bean list on the table
table.setBean(beans);
// ServiceRequest on the repeater (to create the SubUiContexts)
// The prepare paint will set the row with the option "D" as focused
MockRequest request = new MockRequest();
table.preparePaint(request);
// Simulate clearing of scratch map
uic.clearScratchMap();
// Get the focused component
String focusId = uic.getFocussedId();
Assert.assertNotNull("Focus ID should not be null", focusId);
}
Aggregations