最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Primefaces,how to collapse layoutUnit with another button? - Stack Overflow

programmeradmin29浏览0评论

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?

Thanks for help.

PS, early assumed that can write something like this:

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

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

But unfortunately, widgetVar attribute not existing for 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.

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?

Thanks for help.

PS, early assumed that can write something like this:

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

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

But unfortunately, widgetVar attribute not existing for 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.

Share Improve this question edited May 23, 2017 at 12:02 CommunityBot 11 silver badge asked Oct 11, 2012 at 3:51 Rinat TainovRinat Tainov 1,4892 gold badges20 silver badges39 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

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:mandButton 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

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

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')

Working with Primefaces 6.1:

<p:layout style="min-width:400px;min-height:200px;" widgetVar="layoutWdgt">
    <p:layoutUnit position="west" size="100" minSize="40" maxSize="200" collapsible="true">
        West
         <p:mandButton value="Collapse" onclick="PF('layoutWdgt').toggle('west')"/>
    </p:layoutUnit>
    <p:layoutUnit position="center">
        Center
    </p:layoutUnit>
</p:layout>
发布评论

评论列表(0)

  1. 暂无评论