本文介绍了Primefaces,如何用另一个按钮折叠layoutUnit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mojarra-2.1.10上使用primefaces PrimeFaces-3.4,我的整页布局类似于。我如何在顶部制作一个按钮,这将折叠西部layoutUnit?

I am using primefaces PrimeFaces-3.4 on Mojarra-2.1.10, my full page layout is something like this. How I can make a button in the top, that will collapse west layoutUnit?

感谢您的帮助。

PS,早期假设可以这样写:

PS, early assumed that can write something like this:

<layoutUnit position="west" widgetVar='westlayout'> ... </layoutUnit>

//button in the top
<button onlick="westlayout.collapse()"></button>

但遗憾的是,layoutUnit不存在widgetVar属性。

But unfortunately, widgetVar attribute not existing for layoutUnit.

更新1:尝试。没有为我工作,问题是具有更新属性的按钮找不到具有此类标识符的文本,我在一个layoutUnit中尝试,找到了标识符,但也没有用。

UPDATE 1: Found similar question, tried. Didn't worked for me, problem was that button with update attribute cannot find text with such identifier, i tried in one layoutUnit, found identifier,but didn't work too.

推荐答案

根据布局客户端API,您可以通过布局 widgetWar切换layoutUnit:

According to the Layout Client Side API, you can toggle your layoutUnit through layout widgetWar:

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

    ....

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






EDITED


EDITED

从PrimeFaces 4开始,仍支持id映射,但弃用PF('XXX')

Starting in PrimeFaces 4, id mapping is still supported but deprecated in favor of PF('XXX')

对于PrimeFaces 5.0及以上版本,您将支持需要使用PF widgetVar来调用客户端API。因此,不需要使用layoutWdgt.toggle('west')来切换西部布局单元,而是需要使用 PF('layoutWdgt')。toggle('west')

For PrimeFaces 5.0 and above, you will need to use PF widgetVar to call client side API. So instead of using layoutWdgt.toggle('west') to toggle west layout unit, you need to use PF('layoutWdgt').toggle('west')

这篇关于Primefaces,如何用另一个按钮折叠layoutUnit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 08:44