use of com.github.bordertech.wcomponents.WRepeater.SubUIContext in project wcomponents by BorderTech.
the class WRepeater_Test method testRepeaterDefaultIds.
@Test
public void testRepeaterDefaultIds() {
WNamingContext context = new WNamingContext("TEST");
WComponent repeated = new WBeanComponent();
WRepeater repeater = new WRepeater(repeated);
context.add(repeater);
context.setLocked(true);
setActiveContext(new UIContextImpl());
repeater.setBeanList(Arrays.asList("A", "B", "C"));
String prefix = "TEST" + WComponent.ID_CONTEXT_SEPERATOR + WComponent.ID_FRAMEWORK_ASSIGNED_SEPERATOR;
// Repeater ID
Assert.assertEquals("Incorrect default id for repeater", prefix + "0", repeater.getId());
String repeaterId = repeater.getId();
// Repeat root ID
Assert.assertEquals("Incorrect default id for repeater root", repeaterId + "-r", repeater.getRepeatRoot().getId());
// Row IDs
for (UIContext uic : repeater.getRowContexts()) {
// Id has uic row render id in it
int row = ((SubUIContext) uic).getContextId();
String idPrefix = repeaterId + WComponent.ID_CONTEXT_SEPERATOR + "r" + row + WComponent.ID_CONTEXT_SEPERATOR + WComponent.ID_FRAMEWORK_ASSIGNED_SEPERATOR + "0";
try {
UIContextHolder.pushContext(uic);
Assert.assertEquals("Incorrect default id for repeated component", idPrefix, repeated.getId());
} finally {
UIContextHolder.popContext();
}
}
}
use of com.github.bordertech.wcomponents.WRepeater.SubUIContext in project wcomponents by BorderTech.
the class WTable_Test method testTableIdsWithIdnames.
@Test
public void testTableIdsWithIdnames() {
WNamingContext context = new WNamingContext("TEST");
WTable table = new WTable();
table.setTableModel(new AdapterBasicTableModel(new SimpleTableModel(new String[][] { { "1" }, { "3" }, { "2" } })));
WComponent repeated = new WBeanComponent();
table.addColumn(new WTableColumn("dummy", repeated));
context.add(table);
table.setIdName("T");
repeated.setIdName("X");
context.setLocked(true);
setActiveContext(new UIContextImpl());
// Table ID
Assert.assertEquals("Incorrect id for table with idname", "TEST" + WComponent.ID_CONTEXT_SEPERATOR + "T", table.getId());
String tableId = table.getId();
// Table repeater id
Assert.assertEquals("Incorrect id for table repeater", tableId + "-row", table.getRepeater().getId());
// Table repeater root id
Assert.assertEquals("Incorrect id for table repeater root", tableId + "-row-r", table.getRepeater().getRepeatRoot().getId());
String rowPrefix = table.getRepeater().getRepeatRoot().getId();
// Row IDs
for (UIContext uic : table.getRepeater().getRowContexts()) {
// Id has uic row render id in it
int row = ((SubUIContext) uic).getContextId();
String repeatedId = rowPrefix + row + WComponent.ID_CONTEXT_SEPERATOR + "X";
try {
UIContextHolder.pushContext(uic);
Assert.assertEquals("Incorrect id for repeated component with idname", repeatedId, repeated.getId());
} finally {
UIContextHolder.popContext();
}
}
}
use of com.github.bordertech.wcomponents.WRepeater.SubUIContext in project wcomponents by BorderTech.
the class WTable_Test method testTableDefaultIds.
@Test
public void testTableDefaultIds() {
WNamingContext context = new WNamingContext("TEST");
WTable table = new WTable();
table.setTableModel(new AdapterBasicTableModel(new SimpleTableModel(new String[][] { { "1" }, { "3" }, { "2" } })));
WComponent repeated = new WBeanComponent();
table.addColumn(new WTableColumn("dummy", repeated));
context.add(table);
context.setLocked(true);
setActiveContext(createUIContext());
String prefix = "TEST" + WComponent.ID_CONTEXT_SEPERATOR + WComponent.ID_FRAMEWORK_ASSIGNED_SEPERATOR;
// Table ID
Assert.assertEquals("Incorrect default id for table", prefix + "0", table.getId());
String tableId = table.getId();
// Repeater ID
Assert.assertEquals("Incorrect default id for table repeater", tableId + "-row", table.getRepeater().getId());
// Repeater repeat root ID
Assert.assertEquals("Incorrect default id for table repeater root", tableId + "-row-r", table.getRepeater().getRepeatRoot().getId());
String rowPrefix = table.getRepeater().getRepeatRoot().getId();
// Allow for WTableColumn between repeated component
String rowSuffix = "_0a0";
// Row IDs
for (UIContext uic : table.getRepeater().getRowContexts()) {
// Id has uic row render id in it
int row = ((SubUIContext) uic).getContextId();
String idPrefix = rowPrefix + row + WComponent.ID_CONTEXT_SEPERATOR + rowSuffix;
try {
UIContextHolder.pushContext(uic);
Assert.assertEquals("Incorrect default id for repeated component", idPrefix, repeated.getId());
} finally {
UIContextHolder.popContext();
}
}
}
use of com.github.bordertech.wcomponents.WRepeater.SubUIContext in project wcomponents by BorderTech.
the class WTable_Test method testTableInternalIds.
@Test
public void testTableInternalIds() {
WNamingContext context = new WNamingContext("TEST");
WTable table = new WTable();
table.setTableModel(new AdapterBasicTableModel(new SimpleTableModel(new String[][] { { "1" }, { "3" }, { "2" } })));
WComponent repeated = new WBeanComponent();
table.addColumn(new WTableColumn("dummy", repeated));
context.add(table);
context.setLocked(true);
setActiveContext(new UIContextImpl());
// Table ID
Assert.assertEquals("Incorrect internal id for table", WComponent.DEFAULT_INTERNAL_ID + "0", table.getInternalId());
String tableId = table.getInternalId();
// Table Repeater ID
Assert.assertEquals("Incorrect internal id for table repeater", tableId + "b", table.getRepeater().getInternalId());
// Table Repeater root ID
Assert.assertEquals("Incorrect internal id for table repeater root", tableId + "br", table.getRepeater().getRepeatRoot().getInternalId());
String rowPrefix = table.getRepeater().getRepeatRoot().getInternalId();
// Allow for WTableColumn between repeated component
String rowSuffix = "a0a";
// Row IDs
for (UIContext uic : table.getRepeater().getRowContexts()) {
// Id has uic row render id in it
int row = ((SubUIContext) uic).getContextId();
String repeatedId = rowPrefix + row + rowSuffix;
try {
UIContextHolder.pushContext(uic);
Assert.assertEquals("Incorrect internal id for repeated component", repeatedId, repeated.getInternalId());
} finally {
UIContextHolder.popContext();
}
}
}
Aggregations