Jsf 调用tabview中的onchange时,内部带有布尔值的HashMap将重置
我在tabview中有一个Hashmap,第一个选项卡上有两个选项卡,用户可以看到他选择的所有对象,第二个选项卡可以看到他可以选择的所有对象。两者的Hashmap是相同的 XHTML:Jsf 调用tabview中的onchange时,内部带有布尔值的HashMap将重置,jsf,primefaces,Jsf,Primefaces,我在tabview中有一个Hashmap,第一个选项卡上有两个选项卡,用户可以看到他选择的所有对象,第二个选项卡可以看到他可以选择的所有对象。两者的Hashmap是相同的 XHTML: <p:tabView id="tabViewElement" style="margin-top: 5px;min-height: 50px;max-height: 300px;overflow-x: hidden;" dynamic="true" activeIndex="0"> <p:aja
<p:tabView id="tabViewElement" style="margin-top: 5px;min-height: 50px;max-height: 300px;overflow-x: hidden;" dynamic="true" activeIndex="0">
<p:ajax event="tabChange" listener="#{Bean.onTabChangeElement}" update="tabViewElement:productConfs tabViewElement:cardsElements" />
<p:tab id="idTabElementView" title="Elements Sectionnes">
<h:inputText rendered="#{Bean.objectselected}" value="Aucun produit selectionné"/>
<p:dataTable id="productConfs" var="productConf" value="#{Bean.keyAsListForAllElement}" rendered="#{Bean.objectselected}">
<f:facet name="header">
<h:outputText value="ELEMENTS" />
</f:facet>
<p:column headerText="" rendered="#{Bean.listAllElement[productConf]}">
<p:selectBooleanCheckbox value="#{Bean.listAllElement[productConf]}">
<p:ajax listener="#{Bean.checkBoxElement}" update="productConfs" />
</p:selectBooleanCheckbox>
</p:column>
<p:column headerText="Reference" rendered="#{Bean.listAllElement[productConf]}">
<h:outputText value="#{productConf.reference}" />
</p:column>
<p:column headerText="Indice majeur" rendered="#{Bean.listAllElement[productConf]}">
<h:outputText value="#{productConf.majorIndex}" />
</p:column>
<p:column headerText="Indice mineur" rendered="#{Bean.listAllElement[productConf]}">
<h:outputText value="#{productConf.minorIndex}" />
</p:column>
<p:column headerText="Designation" rendered="#{Bean.listAllElement[productConf]}">
<h:outputText value="#{productConf.productConfModel.reference}" />
</p:column>
<p:column headerText="Identifiable" rendered="#{Bean.listAllElement[productConf]}">
<p:selectBooleanCheckbox disabled="true" value="#{productConf.identifiable}" />
</p:column>
</p:dataTable>
</p:tab>
<p:tab id="tabSelectedElement" title="Choisir Elements" style="margin-top: 5px;max-height:400px;overflow-y: scroll;overflow-x: hidden;">
<p:dataTable id="cardsElements" var="cardElement" value="#{Bean.keyAsListForAllElement}">
<f:facet name="header">
<h:outputText value="ELEMENTS" />
</f:facet>
<p:column headerText="">
<p:selectBooleanCheckbox value="#{Bean.listAllElement[cardElement]}">
<p:ajax listener="#{Bean.checkBoxElement}" update="cardsElements" />
</p:selectBooleanCheckbox>
</p:column>
<p:column headerText="Reference">
<h:outputText value="#{cardElement.reference}" />
</p:column>
<p:column headerText="Indice majeur">
<h:outputText value="#{cardElement.majorIndex}" />
</p:column>
<p:column headerText="Indice mineur">
<h:outputText value="#{cardElement.minorIndex}" />
</p:column>
<p:column headerText="Designation">
<h:outputText value="#{cardElement.productConfModel.reference}" />
</p:column>
<p:column headerText="Identifiable">
<p:selectBooleanCheckbox disabled="true" value="#{cardElement.identifiable}" />
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>
我使用Tomcat 7处理primefaces 3.5
有人能帮我吗?问题在哪里?我已经解决了我的问题。我必须删除此侦听器:
<p:ajax event="tabChange" listener="#{Bean.onTabChangeElement}" update="tabViewElement:productConfs tabViewElement:cardsElements" />
并在p:selectBooleanCheckbox listener中添加另一个要更新的组件
<p:ajax listener="#{ConfigurationProductBean.checkBoxElement}" update="cardsElements :form:tabViewElement:productConfs" />
那很好!谢谢你的帮助 你的bean的范围是什么?那么你期望得到什么样的输出呢?当它生成给定的输出时,您将在哪个选项卡上启动?我希望在选项卡之间切换时,hashmap值中的true数不会改变。因为在一种情况下,这是有效的,但在另一种情况下,它是相同的代码。您的
checkBoxElement
方法在做什么?看起来服务器端的值正在更改。为什么不使用调试器而不是系统输出来检查它?只需查看这些值何时被覆盖。该方法在p:growl中显示一条消息。调用event=“tabChange”时,该值将被覆盖。
<p:ajax event="tabChange" listener="#{Bean.onTabChangeElement}" update="tabViewElement:productConfs tabViewElement:cardsElements" />
<p:ajax listener="#{ConfigurationProductBean.checkBoxElement}" update="cardsElements :form:tabViewElement:productConfs" />