6 Replies Latest reply on Dec 14, 2010 6:44 AM by eoin81

    dataTable not updating?!

    eoin81

      Hi Guys,

       

      New to Rich Faces. (Using RF 3.3.3.Final with JSF, Facelets, Deployed on Tomcat6)

       

      I was trying out the dataTable component to filter a list. The backing bean data type of the list being displayed is (java.util.List) List<MyForms>.

       

      The display of the list works fine but the filter onkeyup event seems to fire the AJAX request and a response is returned with what looks like the entire data set for the list. So the table is not refreshed/updated based on the filter text. Nothing happens in the UI at all.

       

      Can anyone spot what Im doing wrong?!

       

      [CODE]

      <h:form>

      <rich:dataTable value="#{form.myForms}" var="items">

       

              <rich:column filterBy="#{items.assetDesc}" filterEvent="onkeyup">

                      <f:facet name="header">Asset Description</f:facet>

                       <h:outputText value="#{items.assetDesc}"/>

              </rich:column>

       

              <rich:column>

                      <f:facet name="header">Asset Address</f:facet>

                      <h:outputText value="#{items.assetAddress}"/>

              </rich:column>

       

      <rich:dataTable>

      </h:form>

      [/CODE]

       

      Cheers! Eoin

        • 1. Re: dataTable not updating?!
          konstantin.mishin

          Post your java code. Seems you are using request scoped bean instead of session scoped.

          • 2. Re: dataTable not updating?!
            eoin81

            Hi Mishin, Thanks for the reply.  I've been trying a slightly different approach but with the same results.

             

            My bean is defined in a flow level xml file, which is managed by spring. (its not defined anywhere else)

             

            <bean id="action" class="com.foo.test.MyAction"/>

             

            <CODE>

            public class MyAction {

             

            public List<Form> getTestRecords(){

             

               List<Form> forms = new ArrayList<Form>();

               Form newForm1 = new Form();

               Form newForm2 = new Form();

             

               newForm1.setName("John");

               newForm1.setAge(23);

             

               newForm2.setName("Mary"); 

               newForm2.setAge("25");

             

               forms.add(newForm1);

               forms.add(newForm2);

             

               return forms;

             

            }

             

            }

            [/CODE]

             

            I then use webflow to hold the result of the getRecords method like follows:

             

            <evaluate expression ="action.getRecords()" result="flowScope.forms" />

             

            Then I use RichFaces to display the data (which it does, its just the sorting/filtering that doesent do anything)

             

            <rich:dataTable rows="1" value="${flowScope.forms}" var="items" reRender="ds" id="dt">

            ...

            </rich:dataTable>

             

            Any ideas? Do I need to register my bean somewhere else?

            Cheers! Eoin

            • 3. Re: dataTable not updating?!
              konstantin.mishin

              Seems it isn't RichFaces problem. But you could share maven or eclipse project with this problem somewhere and we maybe will investigate  it.

              • 4. Re: dataTable not updating?!
                eoin81

                Thanks. I'll see what I can do,

                 

                What I wanted to be clear of is:

                 

                1) For <rich:dataTable/>  the backing bean data type that is bound to the value attribute in the tag can be of type java.util.List for displaying/sorting/filtering

                 

                2) The definition of my bean is correct. ie do I need to add anything like scope to the bean declaration or do I need to declare it as a managed bean in faces-config, but I dont think I do!

                • 5. Re: dataTable not updating?!
                  eoin81

                  I managed to get this working to a certain extent using a custom filtye  (thanks to the example from the livedemo site).

                   

                  I have a dataTable populated with my data from a session scoped managed bean. All works fine.

                   

                  My filter:

                   

                  <rich:column filterExpression="#{fn:containsIgnoreCase(items.assetAddress, bean.currentNameFilterValue)}">
                                              <f:facet name="header">
                                                  <h:selectOneMenu value="#{bean.currentNameFilterValue}">
                                                      <f:selectItems value="#{bean.types}" />
                                                      <a4j:support event="onchange" reRender="dt" />
                                                  </h:selectOneMenu>                              
                                              </f:facet>
                                              <h:outputText id="id2" value="#{items.assetAddress}"/>
                                      </rich:column>

                   

                  My problem now is that when I select an element from the drop down (for example A), a request is fired but the table is not updated. If I then select another element from the drop down (for example B), the request is fired but the table is updated for A. Then next selection, the table is updated for B etc ...! So it seems the first request does not satisfy the expression, but it sets the value in the bean, and so the next request satisfies the condition.

                   

                  I wonder if this is a simple fix? Anyone any ideas?

                  • 6. Re: dataTable not updating?!
                    eoin81

                    Just an update on this for anyone working with in this area (Webflow + RichFaces)

                     

                    I needed to add a global transition to my webflow xml to rerender the page in the above scenario, (because there seemed to be some issues with the initial refresh).

                     

                    xhtml page

                    ...

                    <a4j:support event="onChange" action="#{bean.action}" reRender="dt">

                    ....

                    bean

                     

                    String action(){

                    //do processing

                    return "success"

                    }

                     

                    flow xml

                    <view-state id="currentPage">

                      <transition on="success" to"currentPage"/>

                    </view-state>

                     

                    That works!