1

将 Wicket 框架从 6.x 升级到 8.x 后,我遇到了以下错误。我更新了以下依赖项以将弃用的 TreeTable 代码保留在 wicket 8.x 中。

<dependency>
    <groupId>org.wicketstuff</groupId>
    <artifactId>wicket15-tree</artifactId>
    <version>8.0.0</version>
</dependency>

@SuppressWarnings({ "deprecation" })
private void myTreePage() {
    TreeTable myTestTree = new TreeTable("myTestTreeTable", new DefaultTreeModel(myTestRootNode), cols);
    statusImport();
    myTestTree.setRootLess(true);
    myTestTree.setOutputMarkupId(true);
    addOrReplace(myTestTree);
}




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" xml:lang="en" lang="en">
    <body>
        <wicket:extend>
            <div class="statusMsg"><span wicket:id="runIds"></span></div>
            <div class="query_table_header"><label>Import Table</label></div>
            <div wicket:id="myTestTreeTable"></div>
            <form wicket:id="form">
                <div wicket:id="countFilter">
                     <div class="query_table_header"><label>status</label></div>
                </div>
                <div><label>Entity: </label> <select wicket:id="selectEntity"/> <label>Status: </label> <select wicket:id="selectStatus"/></div>
            <input type="submit" value="select" wicket:id="select"/> <input type="submit" wicket:id="bucket" value="Start Reprocessing" />
            </form>
        </wicket:extend>
    </body>
</html>

正如我发现如果我删除标签然后页面加载没有任何错误。我认为这里的问题是查看标签放置或标签定义。


错误 | 发生异常:org.apache.wicket.markup.MarkupNotFoundException:在 org.apache 的 org.apache.wicket.Component.internalRender(Component.java:2267) 中找不到组件的标记:[TreeTableItem [Component id = 0]]。 org.apache.wicket.extensions.markup.html.tree.table.MiddleColumnsView.onRender(MiddleColumnsView.java:189) 在 org.apache.wicket.Component.internalRender( Component.java:2296) 在 org.apache.wicket.Component.render(Component.java:2227) 在 org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1454) 在 org.apache.wicket.MarkupContainer.renderAll (MarkupContainer.java:1654) 在 org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1629) 在 org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:798) 在 org.apache.wicket.markup。

4

1 回答 1

0

将 TreeTable 类替换为 TableTree 类后,我解决了异常。

请参考以下代码:

    private final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("<root>");
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);

        ITreeProvider<DefaultMutableTreeNode> modelProvider = new TreeModelProvider<DefaultMutableTreeNode>(treeModel, false) {
            private static final long serialVersionUID = 1L;
            @Override
            public IModel<DefaultMutableTreeNode> model(DefaultMutableTreeNode object) {
                return Model.of(object);
            }
        };
        
        TableTree<DefaultMutableTreeNode, String> myTestTree = new TableTree<DefaultMutableTreeNode, String>("myTestTreeTable", createColumns(), modelProvider, Long.MAX_VALUE) {
            private static final long serialVersionUID = 1L;
            @Override
            protected Component newContentComponent(String id, IModel<DefaultMutableTreeNode> model) {
                //return new CheckedFolder<DefaultMutableTreeNode>(id, this, model);
                return new Folder<DefaultMutableTreeNode>(id, this, model);
            }
        };
        
        //myTestTree.getTable().addTopToolbar(new HeadersToolbar<>(myTestTree.getTable(), null));
        //myTestTree.getTable().addBottomToolbar(new NoRecordsToolbar(myTestTree.getTable()));
        myTestTree.setOutputMarkupId(true);
        myTestTree.add(new WindowsTheme());
        //myTestTree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
        //myTestTree.getTable().add(AttributeModifier.replace("class", "table table-striped table-condensed"));
        myTestTree.getTable().add(AttributeModifier.replace("style", "width: 100%; background-color:white;"));
        addOrReplace(myTestTree);

树表日期显示完美,但表列标题的名称未显示在页面中。请参考列创建代码。

    private List<? extends IColumn<DefaultMutableTreeNode, String>> createColumns() {
    columns.add(new TreeColumn<>(new Model("Tree"), "obj.text"));
    columns.add(new PropertyColumn<>(new Model("FileStatus"), "FileStatus", "obj.fileStatus"));
    columns.add(new PropertyColumn<>(new Model("StartDate"), "StartDate", "obj.startDate"));
    columns.add(new PropertyColumn<>(new Model("LastDate"), "LastDate", "obj.lastDate"));
    columns.add(new PropertyColumn<>(new Model("Count"), "Count", "obj.count"));
    return columns;
}



  
于 2020-11-26T19:56:33.633 回答