0

最初のページで、ツリーテーブルをロードするコマンド ボタンを表示します。

ツリーテーブルは表示されますが、expand node is not working.

私はprimefaces 4.0、jsf 2.2を使用しています

ここに私のコードがあります、

最初のページ バッキング Bean

@ManagedBean(name="loadBean")
public class AjaxLoadBean {
private boolean show;
private String currentPage;

public boolean isShow() {
    return show;
}

public void setShow(boolean show) {
    this.show = show;
}

public String getCurrentPage() {
    return currentPage;
}

public void setCurrentPage(String currentPage) {
    this.currentPage = currentPage;
}

public void newPage() {
    show = true;
    currentPage = "treeTable.xhtml";
}
}

先頭ページ

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<h:body>
<h:form>
    <p:commandButton value="Show" actionListener="#{loadBean.newPage}"
        update=":content" />
</h:form>

<h:panelGroup id="content">
    <h:panelGroup rendered="#{loadBean.show}">
        <ui:include src="#{loadBean.currentPage}"></ui:include>
    </h:panelGroup>
</h:panelGroup>
</h:body>
</html>

ツリーテーブル.xhtml

ui:composition タグを削除しました。

<h:form styleClass="form-horizontal">
<p:treeTable value="#{treeTableBean.root}" var="dataElement"
                id="table">
<p:column headerText="No.">
    <h:outputText value="#{dataElement.no}" />
</p:column>

<p:column headerText="Name">
    <h:outputText value="#{dataElement.name}" />
</p:column>

<p:column headerText="select">
    <p:selectBooleanCheckbox value="#{dataElement.select}" />
</p:column>
</p:treeTable>
</h:form>

TreeTableBean

@ManagedBean
public class TreeTableBean implements Serializable{
private static final long serialVersionUID = 1L;
private TreeNode root;

public TreeTableBean() {
    root = new DefaultTreeNode("root", null);

    new DefaultTreeNode(new TreeTableData(2, "N2", true), root);
    new DefaultTreeNode(new TreeTableData(3, "N3", true), root);
    new DefaultTreeNode(new TreeTableData(4, "N4", true), root);

    TreeNode subNode = new DefaultTreeNode(new TreeTableData(5, "N5", true), root);
    new DefaultTreeNode(new TreeTableData(1, "N5.1", true), subNode);
    new DefaultTreeNode(new TreeTableData(2, "N5.2", false), subNode);
    subNode.setExpanded(true);
}

public TreeNode getRoot() {
    return root;
}
}
4

3 に答える 3

0

私もこの問題を抱えていました。以下の手順で解決しました: ステップ 1: XHTML ファイルを webcontent フォルダーに移動します。ステップ 2: webcontent 内のすべてのファイルはパブリック アクセスが許可されているため、セキュリティ上の理由から web.xml に次のエントリを追加する必要があります。

セキュリティ制限については、次のリンクを参照してください: JSF 2: WEB-INF 内の複合コンポーネント

于 2015-05-31T06:52:46.793 に答える
0

両方の Bean を ViewScoped に変更しましたが、動作しています。

Viewscoped は、datatable、tree などのコンポーネントで ajax 呼び出しをサポートするために最低限必要なものです。

私はプライムフェイスフォーラムに投稿し、その情報を得ました。

http://forum.primefaces.org/viewtopic.php?f=3&t=35620#p113774

于 2013-12-29T05:43:29.260 に答える