Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf Primefaces SelectBooleanCheckbox在表单提交时未选中_Jsf_Primefaces_Jsf 2.2 - Fatal编程技术网

Jsf Primefaces SelectBooleanCheckbox在表单提交时未选中

Jsf Primefaces SelectBooleanCheckbox在表单提交时未选中,jsf,primefaces,jsf-2.2,Jsf,Primefaces,Jsf 2.2,我是这个网站的新手,我的问题与primefaces中的SelectBooleanCheckbox有关。 每当我提交表单时,复选框都会被取消选中。 我正在使用动态选项卡视图 以下是我的xhtml代码:- <h:form id="form" > <p:panel id="tagsPanel" > <p:tabView id="tabView" style="background-color:transparent;background-image:none;" var

我是这个网站的新手,我的问题与primefaces中的SelectBooleanCheckbox有关。 每当我提交表单时,复选框都会被取消选中。 我正在使用动态选项卡视图

以下是我的xhtml代码:-

<h:form id="form" >
<p:panel id="tagsPanel" >
<p:tabView id="tabView"  style="background-color:transparent;background-image:none;" var="tabKey" value="#{MBean.Names}"  
      dynamic="true"  >
<p:dataGrid var="appSettingsList"  value="#{appSettingsMBean.tabData[tabKey]}"    columns="1" styleClass="plainDataGrid">
    <h:panelGrid columns="2"  border="0" cellspacing="0" cellpadding="0"  columnClasses="JspContent12 ,JspContent22"  width="100%" >
         <p:column escape="false" >  
<p:selectBooleanCheckbox value="#{appSettingsList.resultValues.checkboxValue}"   style="float:left" id="checkBoxValue"
                     rendered="#{appSettingsList.currentValues != null and appSettingsList.currentValues.size() > 0 and
                      appSettingsList.displayType.equalsIgnoreCase('single') and appSettingsList.dataType.equalsIgnoreCase('boolean')}">
                     </p:selectBooleanCheckbox>
           </p:column>
        </h:panelGrid>
    </p:dataGrid>   
</p:panel>
          <p:panel border="0" id="buttonRow" style="text-align:center;border-width:0;border-style:none;background-image:none;" >           

        <p:commandButton  value="Save"   id="save"  actionListener="#{MBean.saveSettings()}" ajax="false" style="width:130px" />
</p:panel>
</h:form>
更改选项卡并单击“保存btn”时,复选框保持选中状态 但是,当仅单击save btn时,它将被取消选中 如果您有任何帮助,我们将不胜感激……

在这里

<p:commandButton ... ajax="false" />
Ajax已关闭。因此,在提交表单后,将执行整页刷新。复选框未选中表明bean没有正确保持其状态,或者您正在getter方法中执行业务逻辑,这导致它每次都返回一个新模型,而不是保存提交值的模型

您有两种选择:

只需使用ajax。也就是说,去掉ajax=false。如果要在提交时更新视图的某些部分,则只需相应地指定更新属性

确保你的bean不会弄乱状态或getter


大家好,欢迎来到Stack Overflow。问问题时请使用MCVE谢谢您的回复@BalusC,但是,我没有弄乱获得者。此外,当我只是更改并单击提交选项卡而不执行任何其他操作时,复选框的状态保持不变。它仅在表单sunmission上变为null而不执行任何操作。是否是由于选项卡视图dynamic=true