如何从p:selectBooleanCheckbox更改事件提交表单

yan*_*Lar 2 ajax primefaces jsf-2

我正在使用primefaces并处理复杂的表格.我需要隐藏表单的一部分,具体取决于复选框的值

    <p:selectBooleanButton id="input1" .... />
<p:inputText id="input2" />


<!-- the boolean checkbox -->
<p:selectBooleanCheckbox id="checkBox1" value="#{bbean.someBoolValue}" >
    <p:ajax event="change" update=":#{p:component('someParentcComponentsId')}" />
</p:selectBooleanCheckbox>

<!-- some input fields here. These will be rendered depending checkBox1 value -->
<p:panel rendered="#{bbean.someBoolValue}" id="hiddingPanel">   
    <h:panelGrid columns="2" >

        <p:inputText id="input3" />
    </h:panelGrid>
</p:panel>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经完成了这项工作,因此checkBox1点击时,hiddingPanel会显示或隐藏.但有一个问题:在表单中的每个输入值(例如input1,input2)都将丢失,因为"变化" AJAX事件不提交它们的值.

在更新表单之前,如何确保提交所有输入值?

Bal*_*usC 7

只需确保更新真正需要更新的部分.

<p:selectBooleanCheckbox id="checkBox1" value="#{bbean.someBoolValue}" >
    <p:ajax event="change" update="hiddingPanel" />
</p:selectBooleanCheckbox>

<!-- some input fields here. These will be rendered depending checkBox1 value -->
<p:panel id="hiddingPanel">   
    <h:panelGrid columns="2" rendered="#{bbean.someBoolValue}">

        <p:inputText id="input3" />
    </h:panelGrid>
</p:panel>
Run Code Online (Sandbox Code Playgroud)

请注意,我移动rendered到它的直接子节点,原因如下所示:当我想要ajax-update时,为什么我需要在另一个组件中嵌套一个带有render ="#{some}"的组件?