4 Replies Latest reply on Jan 22, 2011 11:15 PM by atmohsin

    filter by for rich:dataTable for invalid filter value is not working

    atmohsin

      Hi

          I am rich:dataTable to display the list of object. I have used filterBy attribute of rich:column

       

       

       

       

       

      This is working fine if i give the valid value for filterby which is present in the table. when i give invalid value to filterby the table is not getting reRender.if i refresh the page the table wont get display.

       

      My difination for the table

       

      <

      rich:dataTable border="1" id=

      "dataTable"

       

       

      binding="#{testBean.dataTable}" width="100%"

       

       

       

       

       

       

       

       

       

       

      Here i have bind the data table the bean and bean is in session scope. I try to remvoed the filter value in backing bean. But  no use. When i remve the table binding it is working fine. I need this for pagination.

      If anybody have inforamtion please let me know

      Thanks in advance

      Mohsin

       

      rendered="#{testBean.dataTable.rowCount>0}" rowClasses="row1, row2">

       

      rows="#{testBean.pageSize}"

       

      value="#{testBean.dataLists}" var="term"

        • 1. filter by for rich:dataTable for invalid filter value is not working
          ilya40umov

          1) Please post the full page code and the bean code if it's possible

          2) Add rich:messages on your page

          3) The solution like this one:

          rendered="#{testBean.dataTable.rowCount>0}"

          does not look good(IMHO). What do you want to do by it?

          • 2. filter by for rich:dataTable for invalid filter value is not working
            atmohsin

            Hi

             

            Find the defination of datatable.

            Let me know if you any information.

             

            Thanks

            Mohsin

             

             

            <rich:dataTable border="1" id="dataTable"

                                binding="#{userBean.dataTable}" width="100%"

                                value="#{userBean.dataLists}" var="user"

                                rows="#{userBean.pageSize}"

                                rendered="#{userBean.dataTable.rowCount>0}" rowClasses="row1, row2"

                                headerClass="tableHeaderStyle"  footerClass="footerHeaderStyle" align="center">

             

                                <rich:column width="5%">

                                    <f:facet name="header">

                                    </f:facet>

                                    <h:selectBooleanCheckbox type="checkbox" id="chkEble" value="#{user.selected}" disabled="#{user.userName == 'admin'}"/>   

                               

                                </rich:column>

             

             

                                <rich:column filterBy="#{user.userName}" filterEvent="onkeyup" width="50%">

                                    <f:facet name="header">

                                        <h:commandLink styleClass="columnHeaderStyle" actionListener="#{userBean.sortDataList}">

                                            <f:attribute name="sortField" value="getUserName" />

                                            <h:outputText value="#{msg.username}" />

                                            <h:outputText value="&#0160;&#9650;" escape="false"

                                                rendered="#{!userBean.sortAscending}" />

                                            <h:outputText value="&#0160;&#9660;" escape="false"

                                                rendered="#{userBean.sortAscending}" />

                                        </h:commandLink>

                                    </f:facet>

                                    <h:outputText value="#{user.userName}"

                                        styleClass="tableDataStyle" />

                                </rich:column>

             

                                <rich:column filterBy="#{user.role.roleName}" filterEvent="onkeyup" width="40%">

                                    <f:facet name="header">

                                        <h:commandLink styleClass="columnHeaderStyle" actionListener="#{userBean.sortDataList}">

                                            <f:attribute name="sortField" value="role.getRoleName" />

                                            <h:outputText value="#{msg.roleName}" />

                                            <h:outputText value="&#0160;&#9650;" escape="false"

                                                rendered="#{!userBean.sortAscending}" />

                                            <h:outputText value="&#0160;&#9660;" escape="false"

                                                rendered="#{userBean.sortAscending}" />

                                        </h:commandLink>

                                    </f:facet>

                                    <h:outputText value="#{user.role.roleName}"

                                        styleClass="tableDataStyle" />

                                </rich:column>

             

                                <rich:column width="5%">

                                    <a4j:commandLink action="#{userForm.loadUser}"

                                        reRender="userModalForm"

                                        oncomplete="Richfaces.showModalPanel('userAddModal');">

                                       

                                        <h:graphicImage value="/images/Edit_Button.gif" alt="Edit"

                                            styleClass="imageStyle"  rendered="#{user.userName != 'admin'}"/>

                                       

                                        <f:setPropertyActionListener target="#{userForm.updatedId}"

                                            value="#{user.id}" />

                                    </a4j:commandLink>

                                </rich:column>

             

                                <f:facet name="footer">

                                    <h:panelGroup>

                                        <a4j:commandButton value="#{msg.first}"

                                            action="#{userBean.pageFirst}"

                                            disabled="#{userBean.dataTable.first == 0}"

                                            reRender="dataTablePanel" />

                                        <a4j:commandButton value="#{msg.prev}"

                                            action="#{userBean.pagePrevious}"

                                            disabled="#{userBean.dataTable.first == 0}"

                                            reRender="dataTablePanel" />

                                        <a4j:commandButton value="#{msg.next}"

                                            action="#{userBean.pageNext}"

                                            disabled="#{userBean.dataTable.first + userBean.dataTable.rows>=userBean.dataTable.rowCount}"

                                            reRender="dataTablePanel" />

                                        <a4j:commandButton value="#{msg.last}"

                                            action="#{userBean.pageLast}"

                                            disabled="#{userBean.dataTable.first +userBean.dataTable.rows>=userBean.dataTable.rowCount}"

                                            reRender="dataTablePanel" />

                                        <h:outputText

                                            value="Page: #{userBean.currentPage} / #{userBean.totalPages}" />

                                        <rich:spacer width="10" />   

                                        <h:outputText

                                                value="#{msg.total} #{userBean.totalNumberOfRecords}" />   

                                    </h:panelGroup>

                                </f:facet>

                            </rich:dataTable>

            • 3. filter by for rich:dataTable for invalid filter value is not working
              ilya40umov

              I think your problem is in the following:

              rendered="#{testBean.dataTable.rowCount>0}"

              and when you apply filter which does not match any entiries your dataTable won't be rendered. Don't use such an approach to hide your data table.

               

               


              • 4. filter by for rich:dataTable for invalid filter value is not working
                atmohsin

                Thanks it is working fine. I made simple mistake.

                Now i am using following rendered="#{userBean.dataListSize>0}" it is working fine

                 

                Thanks a lot

                 

                Mohsin