1

我尝试使用来自 primefaces.org 的展示 tuts 示例。我在我的 xhtml 文件以及 TreeBean.java 中复制了完全相同的文本

但是树形结构永远不会出现在浏览器中(m 使用 IE9)。出现一个空块而不是树。使用树节点时有什么需要注意的吗?

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      
"http://www.w3.org/TR/html4/loose.dtd">

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

<f:view contentType="text/html">
    <h:head>
        <f:facet name="first">
            <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
            <title>PrimeFaces</title>
        </f:facet>
    </h:head>

    <h:body>

        <p:layout fullPage="true">

            <p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
                Header
            </p:layoutUnit>

            <p:layoutUnit position="south" size="100" closable="true" collapsible="true">
                Footer
            </p:layoutUnit>

            <p:layoutUnit position="west" size="175" header="Left" collapsible="true">
                <h:form id="form">
                    <p:tree value="#{treeBean.root}" var="node" id="tree">
                        <p:treeNode id="treeNode">
                            <h:outputText value="#{node}" id="lblNode"/>
                        </p:treeNode>
                    </p:tree>
                </h:form> 
            </p:layoutUnit>

            <p:layoutUnit position="center">
                Welcome to PrimeFaces
            </p:layoutUnit>

        </p:layout>

    </h:body>

</f:view>

4

1 回答 1

0

您还必须创建和复制一个 TreeBean 类。它适用于 primefaces 展示网站上的每个示例,位于 xhtml 的源代码旁边。要使其对 EL 可见,您必须另外注释它 @Named 或 @ManagedBean,并为其提供一些合理的生命周期范围。

//编辑:

@Named
@javax.enterprise.context.SessionScoped
public class TreeBean {  ... }
于 2013-06-23T00:30:55.433 回答