p:layoutUnit内容在p:tree节点选择上未更改 [英] p:layoutUnit content not changing on p:tree node selection

查看:140
本文介绍了p:layoutUnit内容在p:tree节点选择上未更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在<p:tree>节点选择上更新PrimeFaces <p:layoutUnit>的内容.但是,当我选择一个节点时,内容不会更改.刷新页面时,我看到内容已更改.

I am trying to update the content of PrimeFaces <p:layoutUnit> on <p:tree> node selection. However, when I select a node, the content does not change. When I refresh the page I see that the content is changed.

如何在不刷新整个页面的情况下更改内容?

How can I change the content without refreshing the whole page?

我的查看代码是:

<h:body>
    <h:form id="form">
        <p:layout fullPage="true">
            <p:layoutUnit position="north" size="100"  resizable="false" closable="false" collapsible="false">
                <h:outputText value="Top" />
            </p:layoutUnit>
            <p:layoutUnit position="south" size="100" resizable="flase" closable="false" collapsible="false">
                <h:outputText value="Bottom" />
            </p:layoutUnit>
            <p:layoutUnit position="west" size="250" header="Tree" resizable="true" closable="flase" collapsible="true"> 
                <p:tree id="tree"  value="#{treeBean.root}" selection="#{treeBean.selectedNode}"  var="node" selectionMode="single" dynamic="true"  cache="false" >
                    <p:ajax listener="#{treeBean.onNodeSelect}" update="test" event="select"/>
                    <p:treeNode>
                        <h:outputText value="#{node}"/>
                    </p:treeNode>
                </p:tree>
            </p:layoutUnit>
            <p:layoutUnit position="center" id="test">
                <ui:include src="${treeBean.selectedNode.name}.xhtml"/>
            </p:layoutUnit>
        </p:layout>
    </h:form>
</h:body>  

推荐答案

首先,您不应该将布局单元放在表单内,而应该将表单放在布局单元内.

First, you should not put the layout-units inside form, instead put forms inside layout-units.

另一个问题是您有嵌套的表单,而不应该有嵌套的表单.

Another problem is that you have nested forms, you should not have nested forms.

您的表格<h:form id="from"放在错误的位置.您应该将其移至<p:layoutUnit position="west":

Your form <h:form id="from" is at the wrong spot. You should move it inside <p:layoutUnit position="west":

<p:layoutUnit position="west" size="250" header="Tree" resizable="true" closable="flase" collapsible="true"> 
    <h:form id="form">
        <p:tree id="tree"  value="#{treeBean.root}" selection="#{treeBean.selectedNode}"  var="node" selectionMode="single" dynamic="true"  cache="false" >
            <p:ajax listener="#{treeBean.onNodeSelect}" update=":myForm" event="select"/>
            <p:treeNode>
                <h:outputText value="#{node}"/>
            </p:treeNode>
        </p:tree>
    </h:form>
</p:layoutUnit>

还考虑使用h:panelGroup而不是<h:form id="myForm"并更新面板组,因为在那里您不需要h:form:

Also consider using a h:panelGroup instead of <h:form id="myForm" and update the panelgroup, because you don't need that h:form there:

<p:layoutUnit position="center">
    <h:panelGroup id="centerContentPanel">
        <ui:include src="${treeBean.selectedNode.name}.xhtml"/>
    </h:panelGroup>
</p:layoutUnit>

并更新该面板组:

<p:ajax listener="#{treeBean.onNodeSelect}" update="centerContentPanel" event="select"/>

这篇关于p:layoutUnit内容在p:tree节点选择上未更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆