jsf - HashMap with Boolean inside get reset when onchange in tabview is call -


i have 1 hashmap inside tabview 2 tab on first tab user can see object selected on second can see object can select. it's same hashmap both.

xhtml:

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

the second tab works when check or not 1 object can see him on first, when uncheck 1 first tab see him disappear when switch second tab reappear.

i have put on code check how many object value true in hashmap.

bean

private hashmap<product, boolean> listallelement = new hashmap<product, boolean>();  public void ontabchangeelement(tabchangeevent event) {     system.out.println("tab change"); }  public list<product> getkeyaslistforallelement() {     int = 0;     (entry<product, boolean> e : this.listallelement.entryset()) {         if (e.getvalue() == true) {             i++;         }     }     system.out.println("boolean true = " + i);     return new arraylist<product>(this.listallelement.keyset()); } 

output

boolean true = 1 boolean true = 1 boolean true = 1 boolean true = 1 boolean true = 2 tab change boolean true = 2 boolean true = 2 boolean true = 2 boolean true = 2 

i work on primefaces 3.5 tomcat 7.

can me out here, problem?

i have fix problem. have delete listener:

<p:ajax event="tabchange" listener="#{bean.ontabchangeelement}" update="tabviewelement:productconfs tabviewelement:cardselements" /> 

and add coponent update inside p:selectbooleancheckbox listener.

<p:ajax listener="#{configurationproductbean.checkboxelement}" update="cardselements :form:tabviewelement:productconfs" />  

that work fine ! thank !


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -