0 Replies Latest reply on Oct 14, 2011 10:50 AM by chaitanya kakarla

    h:selectBooleanCheckbox valuechangeListner does not work in a rich datatable

    chaitanya kakarla Newbie

      Hello everybody.

      I am having some issues with a selectBooleanCheckbox inside a DataTable, and would appreciate some advice.

       

      The checkbox has a value change Listener and is supposed to trigger the value change listner but that behavior is not working….it does Nothing….

       

      Something interesting is if I put another checkbox outside DataTable and click it for the first time, then click the check Box in the datatable.....it works fine.

       

      Please let me know if I am doing anything wrong...Its a bit urgent. Thx

       




      <a4j:commandButton value="Search" action="#{merchantcustBean.searchQuery}" reRender="resultsPanelChild" rendered="#{!merchantcustBean.flag}"></a4j:commandButton>

       

       

      <a4j:outputPanel id="resultsPanelChild">

                                              <b>

                                              <h:selectBooleanCheckbox value="#{merchantcustBean.flag}" immediate="true" valueChangeListener="#{merchantcustBean.userSelectedCheckBoxParentResults}">

                                                                                      <f:param id="corpId2" name="corpId" value="gfdgfgffg"></f:param>

                                                                                      <a4j:support event="onclick"  ></a4j:support>

                                                                  </h:selectBooleanCheckbox>

                                              <h:outputText value="Parent Search Results" rendered="#{!empty merchantcustBean.parentRecs}" />

                                              </b><br />

                                              <h:outputText style="color: red;" value="Number of parent results: #{merchantcustBean.noofParentrecs}"></h:outputText>

                                              <rich:spacer height="15px" rendered="#{!empty merchantcustBean.parentRecs}"></rich:spacer>

                                              <rich:dataTable value="#{merchantcustBean.parentRecs}" var="parentRec" rendered="#{!empty merchantcustBean.parentRecs}">

                                                        <rich:column>

                                                                  <f:facet name="header">

                                                                            <h:outputText value="Customer Id"></h:outputText>

                                                                  </f:facet>

                                                                  <h:outputText value="#{parentRec.corporatemerchantid}"></h:outputText>

       

                                                        </rich:column>

                                                        <rich:column>

                                                                  <f:facet name="header">

                                                                            <h:outputText value="Customer Name"></h:outputText>

                                                                  </f:facet>

                                                                  <h:outputText value="#{parentRec.corporateName}"></h:outputText>

       

                                                        </rich:column>

                                                        <rich:column>

                                                                  <f:facet name="header">

                                                                            <h:outputText value="Option"></h:outputText>

                                                                  </f:facet>

                                                                  <h:selectBooleanCheckbox value="#{parentRec.parentSearchPanelOption}" immediate="true" valueChangeListener="#{merchantcustBean.userSelectedCheckBoxParentResults}">

                                                                                      <f:param id="corpId" name="corpId" value="#{parentRec.corporatemerchantid}"></f:param>

                                                                                      <a4j:support event="onclick"  ></a4j:support>

                                                                  </h:selectBooleanCheckbox>

                                              <h:selectBooleanCheckbox  value="#{merchantcustBean.searchSeperate}" immediate="true"  valueChangeListener="#{merchantcustBean.userSelectedCheckBoxParentResults}" >

                                                        <a4j:support  event="onclick"  ></a4j:support>

                                              </h:selectBooleanCheckbox>

                                                        </rich:column>

       

       

                                              </rich:dataTable>

       

                                    </a4j:outputPanel>

       

       

       

       

      public void userSelectedCheckBoxParentResults(ValueChangeEvent ve){
      
                          logger.info("Action event: "+ getSearchSeperate() + ve.getNewValue() + "   " + ve.getOldValue());
                          //get the user selected parent corporate Id
      
                          Integer userSelected_corporateId = (Integer) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("corpId");
                          Boolean bool = (Boolean) ve.getNewValue();
                          if(userSelected_corporateId != null){
                                    // Here disable all other parents check flags once a user selects the parent...
      
                                    for(DCorporateMerchant rec : parentRecs){
                                              if(rec.getCorporatemerchantid() != userSelected_corporateId){
                                                        // disable the checks boxes and rerender the table
                                                        if(bool == Boolean.TRUE){
                                                                  rec.setParentSearchPanelOption(Boolean.FALSE);
                                                        } else{
                                                                  rec.setParentSearchPanelOption(Boolean.TRUE);
                                                        }
      
                                              }
      
                                    }
      
                          }
      
      
      
                }
      
      

       

      Thank you,

      Chaitanya