diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java index cb16e4ac9a..d4b97f0dcf 100644 --- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java +++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java @@ -57,12 +57,10 @@ import org.apache.myfaces.tobago.layout.PaginatorMode; import org.apache.myfaces.tobago.layout.ShowPosition; import org.apache.myfaces.tobago.layout.TextAlign; -import org.apache.myfaces.tobago.model.ExpandedState; import org.apache.myfaces.tobago.model.Selectable; import org.apache.myfaces.tobago.model.SheetState; import org.apache.myfaces.tobago.model.SortedColumn; import org.apache.myfaces.tobago.model.SortedColumnList; -import org.apache.myfaces.tobago.model.TreePath; import org.apache.myfaces.tobago.renderkit.RendererBase; import org.apache.myfaces.tobago.renderkit.css.BootstrapClass; import org.apache.myfaces.tobago.renderkit.css.CssItem; @@ -490,7 +488,6 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh final boolean showHeader = sheet.isShowHeader(); final Markup sheetMarkup = sheet.getMarkup() != null ? sheet.getMarkup() : Markup.NULL; - final ExpandedState expandedState = sheet.isTreeModel() ? sheet.getExpandedState() : null; final UIComponent before = sheet.getFacet(Facets.BEFORE); if (before != null) { @@ -589,11 +586,8 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh LOG.debug("list " + sheet.getValue()); } - if (sheet.isTreeModel()) { - final TreePath path = sheet.getPath(); - if (sheet.isFolder() && expandedState.isExpanded(path)) { - expandedValue.add(rowIndex); - } + if (sheet.isTreeModel() && sheet.isFolder() && sheet.getExpandedState().isExpanded(sheet.getPath())) { + expandedValue.add(rowIndex); } writer.startElement(HtmlElements.TR); @@ -601,8 +595,7 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh final boolean selected = selectedRows.contains(rowIndex); final String parentId = sheet.getRowParentClientId(); if (parentId != null) { - // TODO: replace with - // todo writer.writeIdAttribute(parentId + SUB_SEPARATOR + AbstractUITree.SUFFIX_PARENT); + // TODO: replace with writer.writeIdAttribute(parentId + SUB_SEPARATOR + AbstractUITree.SUFFIX_PARENT); // todo like in TreeListboxRenderer writer.writeAttribute(DataAttributes.TREE_PARENT, parentId, false); } @@ -635,8 +628,7 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh column instanceof AbstractUIColumn ? ((AbstractUIColumn) column).getVerticalAlign() : null), column.getCustomClass()); - if (column instanceof AbstractUIColumnSelector) { - final AbstractUIColumnSelector selector = (AbstractUIColumnSelector) column; + if (column instanceof AbstractUIColumnSelector selector) { writer.startElement(HtmlElements.INPUT); writer.writeNameAttribute(sheetId + "_data_row_selector_" + rowIndex); Selectable currentSelectable = getSelectionMode(selectable, selector); @@ -655,19 +647,17 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh BootstrapClass.FORM_CHECK_INLINE, TobagoClass.SELECTED); writer.endElement(HtmlElements.INPUT); - } else /*if (normalColumn instanceof AbstractUIColumnNode)*/ { - if (column.getChildCount() > 0) { - for (int k = 0; k < column.getChildCount(); k++) { - column.getChildren().get(k).encodeAll(facesContext); + } else if (column instanceof AbstractUIColumnNode) { + column.encodeAll(facesContext); + } else { + final int childCount = column.getChildCount(); + if (childCount > 0) { + final List children = column.getChildren(); + for (int k = 0; k < childCount; k++) { + children.get(k).encodeAll(facesContext); } } - } /*else { - final List children = sheet.getRenderedChildrenOf(normalColumn); - for (final UIComponent grandKid : children) { - grandKid.encodeAll(facesContext); - } - }*/ - + } writer.endElement(HtmlElements.TD); } else if (column instanceof AbstractUIColumnPanel) { panel = (AbstractUIColumnPanel) column; @@ -722,7 +712,6 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh writer.endElement(HtmlElements.TD); if (!autoLayout) { writer.startElement(HtmlElements.TD); -// writer.write(" "); writer.startElement(HtmlElements.DIV); writer.endElement(HtmlElements.DIV); writer.endElement(HtmlElements.TD); @@ -733,7 +722,6 @@ private void encodeTableBody(final FacesContext facesContext, final AbstractUISh writer.endElement(HtmlElements.TBODY); writer.endElement(HtmlElements.TABLE); writer.endElement(HtmlElements.DIV); -// END RENDER BODY CONTENT } private static Selectable getSelectionMode(Selectable selectable, AbstractUIColumnSelector selector) { diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/70-tree/Sheet_Tree.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/70-tree/Sheet_Tree.xhtml index 3ad000cccb..4297d22b93 100644 --- a/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/70-tree/Sheet_Tree.xhtml +++ b/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/70-tree/Sheet_Tree.xhtml @@ -46,7 +46,7 @@ ... - + diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.test.js index 8eea15f397..8a8a5121a0 100644 --- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.test.js +++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.test.js @@ -18,15 +18,31 @@ import {elementByIdFn, querySelectorAllFn, querySelectorFn} from "/script/tobago-test.js"; import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js"; -it("There must be no horizontal scrollbar", function (done) { +it("Open the 'World' node to see 'Carib' and 'Africa'", function (done) { const reset = elementByIdFn("page:mainForm:reset") const treeNodes = querySelectorAllFn("#page\\:mainForm\\:sheet tobago-tree-node"); const toggleWorld = querySelectorFn("#page\\:mainForm\\:sheet\\:6\\:nameCol .tobago-toggle"); - const spanWorld = querySelectorFn("#page\\:mainForm\\:sheet\\:6\\:nameCol span.form-control-plaintext"); - const spanCarib = querySelectorFn("#page\\:mainForm\\:sheet\\:7\\:nameCol span.form-control-plaintext"); - const spanAfrica = querySelectorFn("#page\\:mainForm\\:sheet\\:8\\:nameCol span.form-control-plaintext"); + const spanWorld = querySelectorFn("#page\\:mainForm\\:sheet\\:6\\:nameOut span.form-control-plaintext"); + const spanCarib = querySelectorFn("#page\\:mainForm\\:sheet\\:7\\:nameOut span.form-control-plaintext"); + const spanAfrica = querySelectorFn("#page\\:mainForm\\:sheet\\:8\\:nameOut span.form-control-plaintext"); const test = new JasmineTestTool(done); + if (treeNodes().length !== 12) { + // test.fail("Must be a number of 12 tree nodes!"); + console.error("Must be a number of 12 tree nodes!"); + } + if (reset() === null) { + // test.fail("reset button not found!"); + console.error("reset button not found!"); + } + if (toggleWorld() === null) { + // test.fail("toggleWorld not found!"); + console.error("toggleWorld not found!"); + } + if (spanWorld() === null) { + // test.fail("spanWorld not found!"); + console.error("spanWorld not found!"); + } test.setup(() => treeNodes().length === 12 && spanWorld().textContent === "World" && spanCarib().textContent !== "Carib" diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.xhtml index a0c5e78823..3c26c36dcf 100644 --- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.xhtml +++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/70-tree/Sheet_Tree.xhtml @@ -24,7 +24,7 @@ - +