Search in sources :

Example 16 with SubUIContext

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();
        }
    }
}
Also used : SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) Test(org.junit.Test)

Example 17 with SubUIContext

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();
        }
    }
}
Also used : SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) Test(org.junit.Test)

Example 18 with SubUIContext

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();
        }
    }
}
Also used : SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) Test(org.junit.Test)

Example 19 with SubUIContext

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();
        }
    }
}
Also used : SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) SubUIContext(com.github.bordertech.wcomponents.WRepeater.SubUIContext) Test(org.junit.Test)

Aggregations

SubUIContext (com.github.bordertech.wcomponents.WRepeater.SubUIContext)19 Test (org.junit.Test)14 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)4 UIContext (com.github.bordertech.wcomponents.UIContext)2 RowIdWrapper (com.github.bordertech.wcomponents.WTable.RowIdWrapper)2 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)1 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)1 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WDataTable (com.github.bordertech.wcomponents.WDataTable)1 WDataTableRowRenderer (com.github.bordertech.wcomponents.WDataTableRowRenderer)1 WRepeater (com.github.bordertech.wcomponents.WRepeater)1 WTable (com.github.bordertech.wcomponents.WTable)1 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 TreeNode (com.github.bordertech.wcomponents.util.TreeNode)1 ArrayList (java.util.ArrayList)1