【问题标题】:Primefaces Collapse LayoutUnit with another buttonPrimefaces 用另一个按钮折叠 LayoutUnit
【发布时间】:2014-08-11 08:58:06
【问题描述】:

我一直在尝试添加一些功能来展开/折叠 primefaces 中的 layoutUnit,但我似乎无法让它工作。我在这里找到了另外两个答案,但它们都不适合我:

Primefaces, how to collapse layoutUnit using some script or jquery function

Primefaces,how to collapse layoutUnit with another button?

例如我测试了以下代码:

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

    <h:head>

    </h:head>
    <h:body>
        <pf:layout fullPage="true" widgetVar="layoutWdgt">
            <pf:layoutUnit position="north" size="100" header="Top" resizable="true" closable="true" collapsible="true">
                <h:form>
                    <pf:commandButton value="Toggle" onclick="layoutWdgt.toggle('west')"/>
                </h:form>
            </pf:layoutUnit>

            <pf:layoutUnit position="west" size="200" header="Left" resizable="true" closable="true" collapsible="true">
                <h:form>
                    <h:outputText value="West Layout unit"/>
                </h:form>
            </pf:layoutUnit>
            <pf:layoutUnit position="center">
                <h:outputText value="Center Layout unit"/>
            </pf:layoutUnit>
        </pf:layout>
    </h:body>
</html>

这行不通。西部布局单元标题上的默认展开折叠图标展开/折叠西部布局单元,但是北部布局单元中的“切换”按钮似乎只是重新加载页面而不更改任何内容。

这是使用 primefaces 5。有什么想法吗?

【问题讨论】:

    标签: jquery jsf-2 primefaces


    【解决方案1】:

    好的,因为你需要使用'PF'函数来获取布局小部件,即:

     <pf:commandButton value="Toggle" onclick="PF('layoutWdgt').toggle('west')"/>
    

    虽然我指定的其他帖子中没有提到这一点,但我只能假设这在以后的 PrimeFaces 版本中变得必要。

    【讨论】:

      猜你喜欢
      • 2012-10-01
      • 2021-10-11
      • 2019-06-25
      • 1970-01-01
      • 2014-08-06
      • 2019-09-27
      • 1970-01-01
      • 1970-01-01
      • 2021-10-28
      相关资源
      最近更新 更多