JSF PrimeFaces overlayPanel提交值 [英] JSF PrimeFaces overlayPanel submit value
问题描述
我想使用以下复选框将值表单jsf页面从overlayPanel提交到bean:
I would like to submit value form jsf page to bean from overlayPanel with checkbox like this:
要显示覆盖面板和ajax提交,我使用以下代码,并在调试器中看到它没问题:
To show overlay panel and ajax submission I use this code, and see it's OK in debugger:
<p:commandButton id="joinBtn" value="Basic" type="button" disabled="#{dataPropertyCurrent.notJoinable}"/>
<p:overlayPanel id="joinPanel" for="joinBtn" appendToBody="true" dynamic="false">
<f:facet name="header">Details</f:facet>
<p:dataList value="#{treeBean.getDataPropsCouldBeJoinedWith(dataPropertyCurrent)}" type="definition" var="dataJoinVal">
<h:panelGrid columns="2" cellpadding="10">
<h:column>
<p:selectBooleanCheckbox value="#{dataJoinVal.checked}" id="cbID">
<p:ajax event="change" update="cbID" partialSubmit="true"/>
</p:selectBooleanCheckbox>
</h:column>
<h:column>
<h:outputText value="#{dataJoinVal.caption}" />
</h:column>
</h:panelGrid>
</p:dataList>
<!--<p:commandButton value="Apply" id="btnApplyJoin" type="button" process="@parent" />-->
<h:outputLabel value="ID: #{dataPropertyCurrent.joinDataPropertyId}" />
</p:overlayPanel>
但是在此之后,当overlayPanel隐藏并使用以下代码按下表单提交按钮时:
But after it when the overlayPanel is hidden and form submit button being pressed with this code:
<p:commandButton value="Apply join" update="joinAccordionPanel,dsAccordionPanelMain" actionListener="#{treeBean.applyJoinOptions}" />
- 它再次将"false"设置为bean布尔值.
那么如何正确地将overlayPanel值提交给bean?
So how to submit overlayPanel value to bean properly?
PrimeFaces版本:3.5
PrimeFaces version: 3.5
推荐答案
I've found explanation here: http://forum.primefaces.org/viewtopic.php?f=3&t=30550#p97737:
如果您使用的是appendToBody,则强烈建议在overlayPanel组件内有一个用于包装所有输入字段和按钮的表单.这是您在上一个解决方案中所做的.但是,这意味着您不能放置由于嵌套表单的限制,xhtml页面中另一个表单内部的overlayPanel最好的解决方案通常是避免在并非绝对必要的地方使用appendToBody."
"If you are using appendToBody, it's strongly recommended to have a form inside the overlayPanel component that wraps all of the input fields and buttons. This is what you have done in your last solution. However, this means that you cannot place the overlayPanel inside another form in the xhtml page because of the limitation on nesting forms. The best solution is typically to avoid appendToBody wherever it's not absolutely necessary."
修改
我已经在overlayPanel内部添加了< h:form>
,现在可以正常使用了:
I've added <h:form>
inside overlayPanel, and now it works fine:
<p:overlayPanel id="joinPanel" for="joinBtn" appendToBody="true" dynamic="true" >
<h:form id="formTmp">
<f:facet name="header">Details</f:facet>
<p:dataList value="#{treeBean.getDataPropsCouldBeJoinedWith(dataPropertyCurrent)}" type="definition" var="dataJoinVal">
<h:panelGrid columns="2" cellpadding="10">
<h:column>
<p:selectBooleanCheckbox value="#{dataJoinVal.checked}" id="cbID">
<p:ajax event="change" update="cbID" partialSubmit="true"/>
</p:selectBooleanCheckbox>
</h:column>
<h:column>
<h:outputText value="#{dataJoinVal.caption}" />
</h:column>
</h:panelGrid>
</p:dataList>
</h:form>
</p:overlayPanel>
这篇关于JSF PrimeFaces overlayPanel提交值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!