3 Replies Latest reply on Jun 26, 2009 1:25 PM by rajesha Indurthi

    issues with rich:dataTable

    rajesha Indurthi Newbie

      Hi there,
      I have been having this issue consistently with rich:dataTable. This is what Iam trying to do. I have a selectCheckBox on the header of the data table, on clicking the select checkbox Iam invoking an action listener which sets a boolean flag on all my data items over which my data table is iterating. Iam reRendering the datatable. Even though my boolean flags are set the selectCheckbox components assosiated, which are present in each row of the datatable are not being selected. i.e. in short the rich:dataTable is not reflecting the model changes on reRendering the data table, why is this so?? is there some piece which Iam missing. Please do guide me on this issue. Thanks in advance!!!

        • 1. Re: issues with rich:dataTable
          Ilya Shaikovsky Master

          your a4j:support should be ajaxSingle=true

          • 2. Re: issues with rich:dataTable
            rajesha Indurthi Newbie

            Hi,
            Thanks for the reply . I applied the ajaxSingle="true", to my a4j:support component as below

            <h:selectBooleanCheckbox id="selectBox" value="#{searchResultsBean.selectAllCheckBox}" immediate="true" style="margin-right:40px" >
             <a4j:support id="checkBoxsupport" event="onclick" ajaxSingle="true" reRender="searchResultsPanel" actionListener="#{searchResultsBean.selectAllListener}"/>
             </h:selectBooleanCheckbox>


            But on rerendering my datatable, it still does not update the check boxes in my datatable with the new value with which they are set in the actinListener. Why is the updated model data not being rendered when I reRender the rich:dataTable. The same piece of code seems to work with plain h:dataTable. Is this a known issue with rich:dataTable, please do guide me through this. I really appreciate your help. Thanks in advance.


            • 3. Re: issues with rich:dataTable
              rajesha Indurthi Newbie

              Hi,

              Let me explain to you exactly what Iam doing. Iam invoking an action listener from a <h:selectBooleanCheckbox> using a4j support. Code snippet :

              <h:selectBooleanCheckbox id="selectBox" value="#{searchResultsBean.selectAllCheckBox}" immediate="true" style="margin-right:40px" >
               <a4j:support id="checkBoxsupport" event="onclick" ajaxSingle="true" reRender="dataTablePanel" actionListener="#{searchResultsBean.selectAllListener}"/>
               </h:selectBooleanCheckbox>


              This selectBox is calling a actionListener which is intun updating the model to which the data table is bound to.

              code snippet of action listener :
              public void selectAllListener(final ActionEvent event)
               {
              
               UIComponent component = event.getComponent();
               HtmlSelectBooleanCheckbox checkBoxComponent = (HtmlSelectBooleanCheckbox) component.findComponent("selectBox");
              
               Boolean checkValue = (Boolean) checkBoxComponent.getValue();
               System.out.println("the checked value is:" + checkValue);
              
               if (checkValue)
               {
               selectAllCheckBox = true;
               List searchResults = (List) data.getValue();
               Iterator resultsIter = searchResults.iterator();
               while (resultsIter.hasNext())
               {
               SearchResultVO dataItem = (SearchResultVO) resultsIter.next();
               dataItem.setSelected(true);
               }
               }
               else
               {
               selectAllCheckBox = false;
               List searchResults = (List) this.getData().getValue();
               Iterator resultsIter = searchResults.iterator();
               while (resultsIter.hasNext())
               {
               SearchResultVO dataItem = (SearchResultVO) resultsIter.next();
               dataItem.setSelected(false);
               }
              
               }
              
               }


              The rich:dataTable is bound to the data attribute on the backing bean, code snippet for rich:dataTable on the jsp :
              <a4j:outputPanel id="dataTablePanel">
               <rich:dataTable style="border-bottom-width:1px;" value="#{SEARCH_RESULTS}" var="hit" id="searchresults" rendered="#{SEARCH_RESULTS != null && not empty SEARCH_RESULTS_SIZE}"
               headerClass="center" width="100%" binding="#{searchResultsBean.data}" rows="20" cellpadding="0" cellspacing="0">
              ...
              ...
              ..
              </rich:dataTable>


              I see that even though the listener is called and data is updated on rerendering the data table these changes are not being refelcted.

              Hope I was able to convey my problem. Please do help me thorugh this. I really appreciate your help. Thanks in advance