我是这个网站的新手我的问题与primefaces中的SelectBooleanCheckbox有关。 每当我提交表单时,都会取消选中该复选框。 我正在使用动态tabview。
这是我的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时,复选框仍保持选中状态 但是,当仅点击保存btn时,它将被取消选中 任何帮助将不胜感激......
答案 0 :(得分:0)
下面,
<p:commandButton ... ajax="false" />
Ajax已关闭。因此,在提交表单后执行整页刷新。取消选中复选框表示bean没有正确保持其状态,或者您在getter方法中执行业务逻辑,这导致它每次都返回一个全新的模型,而不是持有提交的值。
您有2个选项:
只需使用ajax即可。即摆脱ajax="false"
。如果您打算在提交时更新视图的某些部分,请相应地指定update
属性。
确保您的豆子不会与州或吸气者混淆。