/** * Returns the first child of this component. * * @return The first child, or null if no children. */ public BaseComponent getFirstChild() { return getChildAt(0); }
/** * Returns the last child of this component. * * @return The last child, or null if no children. */ public BaseComponent getLastChild() { return getChildAt(getChildCount() - 1); }
/** * Destroys the child component corresponding to the model object at the specified index. * * @param modelIndex The index of the model object. */ protected void destroyChild(int modelIndex) { if (paginator.inRange(modelIndex)) { BaseComponent child = parent.getChildAt(getChildIndex(modelIndex)); ModelAndView<T, M> linkedView = linkedViews == null ? null : linkedViews.get(child); if (linkedView != null) { linkedViews.remove(child); linkedView.destroy(); } child.destroy(); } }
/** * Returns the sibling of this component at the specified offset. * * @param offset Offset from this component. For example, 2 would mean the second sibling * following this component. * @return The requested sibling, or null if none exists at the requested offset. */ private BaseComponent getRelativeSibling(int offset) { int i = getIndex(); i = i == -1 ? -1 : i + offset; return i < 0 || i >= getParent().getChildCount() ? null : getParent().getChildAt(i); }
@Test public void testForm() throws Exception { BaseComponent root = PageUtil.createPage("web/org/carewebframework/ui/sharedforms/listviewForm.fsp", null).get(0); TestController controller = new TestController(); root.wireController(controller); ElementPlugin dummy = new ElementPlugin(); controller.onLoad(dummy); controller.requestData(); assertEquals(10, controller.model.size()); Grid grid = (Grid) root.findByName("grid"); Rows rows = grid.getRows(); assertEquals(10, rows.getChildCount()); assertEquals("Item #2.3", ((ILabeled) rows.getChildAt(1).getChildAt(2)).getLabel()); assertEquals("Test Title", controller.getCaption()); assertEquals("Header3", ((Column) grid.getColumns().getLastChild()).getLabel()); assertEquals(":1:false;0:33%;1:33%;2:33%", controller.getLayout()); controller.setLayout(":2:true;0:20%;1:30%;2:50%"); assertEquals(":2:true;0:20%;1:30%;2:50%", controller.getLayout()); } }