1
votes

I would like to submit value form jsf page to bean from overlayPanel with checkbox like this: enter image description here

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>

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}" />
  • it sets "false" to bean boolean value again.

So how to submit overlayPanel value to bean properly?

PrimeFaces version: 3.5

1
What do you mean by it sets "false" to bean boolean value again.? Is the value of the boolean true at any time or is it a non primitive Boolean? - user1983983
Firstly the bean boolean value was set to 'true' via ajax event on checkbox ticked, but after it when "submit" button pressed to transfer some more form data - it attempts to set 'false' to the bean boolean var. - Sergii
Could you post the code of treeBean.applyJoinOptions? - user1983983
Nothing interesting here, just iterating POJO list containing boolean vals. - Sergii

1 Answers

1
votes

I've found explanation here: http://forum.primefaces.org/viewtopic.php?f=3&t=30550#p97737:

"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."

Edit

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>