当折叠设置为 true 时,Primefaces 面板显示为打开
Primefaces panels appear open when collapsed is set to true
默认情况下,当页面加载时面板显示关闭,因为我有属性 collapsed="true"。我希望当我自动编辑添加时面板更新,更新工作正常但所有面板都显示为打开,即使我已将折叠设置为 true。我不知道为什么会这样。有谁知道为什么?以及如何解决这个问题?
addView.xhtml:
<body>
<h:outputStylesheet name="./../../resources/css/cssLayout.css"/>
<ui:composition template="./../../Layouts/LayoutGeneral.xhtml">
<ui:define name="content">
<h1 style="text-align: center">Adds</h1> <br/>
<h:form id="allAddsId">
<ui:repeat value="#{addBean.allAdds}" var="add" >
<p:panel id="basic" header="#{add.title}" style="margin-bottom:20px" toggleable="true" collapsed="true" styleClass="">
<p:ajax event="toggle"/>
<h:panelGrid columns="2" style="width:100%">
<p:outputLabel value="#{add.description}" />
</h:panelGrid> <br/>
<p:separator/>
<p:commandButton value="Edit" oncomplete="PF('detail').show();" update="detailAdd" action="#{addBean.setAddAux(add)}"/>
<p:growl id="growl" showDetail="true" sticky="false" />
</p:panel>
</ui:repeat>
</h:form>
<p:dialog id="detail" header="Edit Add" widgetVar="detail">
<p:outputPanel id="detailAdd">
<h:form>
<p:outputLabel value="Title"/><br/>
<p:inputTextarea id="titleEdit" value="#{addBean.addAux.title}" rows="2" cols="50" counter="displayTE" maxlength="50" counterTemplate="{0} caracteres restantes" autoResize="false" required="true" requiredMessage="Title necesaria"/> <br/>
<p:outputLabel id="displayTE"/> <br/> <br/>
<p:outputLabel value="Description"/> <br/>
<p:inputTextarea id="opcion1" value="#{addBean.addAux.description}" rows="6" cols="50" counter="displayDE" maxlength="200" counterTemplate="{0} caracteres restantes" autoResize="false" required="true" requiredMessage="Description necesaria"/> <br/>
<p:outputLabel id="displayDE"/> <br/> <br/>
<p:separator/> <br/>
<h:panelGrid columns="1">
<p:commandButton value="Save" action="#{addBean.editAdd(addBean.addAux)}" onclick="detail.hide()" update=":allAddsId"/>
</h:panelGrid>
</h:form>
</p:outputPanel>
</p:dialog>
</ui:define>
</ui:composition>
</body>
好的,我找到了解决办法!!我不知道这是不是最好的答案,但我来了..
我正在做 somo 测试,我删除了面板声明下的 p:ajax event="toggle",现在可以使用了!!当我编辑添加时,添加列表会自动更新并且面板出现折叠!!我不明白为什么删除它会起作用所以如果有人知道请随时告诉我!
希望这对某人有所帮助!
默认情况下,当页面加载时面板显示关闭,因为我有属性 collapsed="true"。我希望当我自动编辑添加时面板更新,更新工作正常但所有面板都显示为打开,即使我已将折叠设置为 true。我不知道为什么会这样。有谁知道为什么?以及如何解决这个问题?
addView.xhtml:
<body>
<h:outputStylesheet name="./../../resources/css/cssLayout.css"/>
<ui:composition template="./../../Layouts/LayoutGeneral.xhtml">
<ui:define name="content">
<h1 style="text-align: center">Adds</h1> <br/>
<h:form id="allAddsId">
<ui:repeat value="#{addBean.allAdds}" var="add" >
<p:panel id="basic" header="#{add.title}" style="margin-bottom:20px" toggleable="true" collapsed="true" styleClass="">
<p:ajax event="toggle"/>
<h:panelGrid columns="2" style="width:100%">
<p:outputLabel value="#{add.description}" />
</h:panelGrid> <br/>
<p:separator/>
<p:commandButton value="Edit" oncomplete="PF('detail').show();" update="detailAdd" action="#{addBean.setAddAux(add)}"/>
<p:growl id="growl" showDetail="true" sticky="false" />
</p:panel>
</ui:repeat>
</h:form>
<p:dialog id="detail" header="Edit Add" widgetVar="detail">
<p:outputPanel id="detailAdd">
<h:form>
<p:outputLabel value="Title"/><br/>
<p:inputTextarea id="titleEdit" value="#{addBean.addAux.title}" rows="2" cols="50" counter="displayTE" maxlength="50" counterTemplate="{0} caracteres restantes" autoResize="false" required="true" requiredMessage="Title necesaria"/> <br/>
<p:outputLabel id="displayTE"/> <br/> <br/>
<p:outputLabel value="Description"/> <br/>
<p:inputTextarea id="opcion1" value="#{addBean.addAux.description}" rows="6" cols="50" counter="displayDE" maxlength="200" counterTemplate="{0} caracteres restantes" autoResize="false" required="true" requiredMessage="Description necesaria"/> <br/>
<p:outputLabel id="displayDE"/> <br/> <br/>
<p:separator/> <br/>
<h:panelGrid columns="1">
<p:commandButton value="Save" action="#{addBean.editAdd(addBean.addAux)}" onclick="detail.hide()" update=":allAddsId"/>
</h:panelGrid>
</h:form>
</p:outputPanel>
</p:dialog>
</ui:define>
</ui:composition>
</body>
好的,我找到了解决办法!!我不知道这是不是最好的答案,但我来了..
我正在做 somo 测试,我删除了面板声明下的 p:ajax event="toggle",现在可以使用了!!当我编辑添加时,添加列表会自动更新并且面板出现折叠!!我不明白为什么删除它会起作用所以如果有人知道请随时告诉我!
希望这对某人有所帮助!