1 2 Previous Next 16 Replies Latest reply on Oct 29, 2012 8:42 AM by kakuda kakuda

    <a4j:poll> always call rich:dataTable value method.

    Paul Wicher Newbie

      Hi,

      I have some problem with poll and rich:dataTable. It seems like poll always calls table value method. Here is my code:

       

          <a4j:region>

                            <a4j:poll id="poll" interval="5000" enabled="true"  />

           </a4j:region>

            <h:form>

                        <rich:dataTable

                          value="#{pollTestBean.loadTasks()}"

                          var="task"

                          rows="8"

                          id="tasksTable" >

                          <rich:column>

                              <h:outputText value="#{task.executionDate}" id="taskExecutionDate"/>

                          </rich:column>

                          <rich:column>

                              <h:outputText value="#{task.businessName}" id="taskName"/>

                          </rich:column>

                          <f:facet name="footer">

                          <h:panelGrid columns="1" style="text-align:center;margin:auto" >

                              <rich:dataScroller renderIfSinglePage="true" maxPages="5" fastControls="hide" boundaryControls="auto"/>

                          </h:panelGrid>

                      </f:facet>

                      </rich:dataTable>

          </h:form>

       

      And my bean:

       

      @ManagedBean(name = "pollTestBean")

      @SessionScoped

      public class PollTestBean {

       

          private List<Task> tasks = null;

       

          public PollTestBean() {

          }

       

          public List<Task> loadTasks() {

              System.out.println("loadTasks called");

              code for loading tasks....

              return tasks;

          }

      }

        • 1. Re: <a4j:poll> always call rich:dataTable value method.
          Paul Wicher Newbie

          Sorry, I was still editing the question and accidently post it.

          Anyway I found "loadTasks called" in my logs every 5 seconds (everytime poll is called).

          I also found similar problem here https://community.jboss.org/thread/152782 but I use rich faces 4.0 and workaraounds with "limitToList" and "renderRegionOnly" won't work since those atributes no longer exist.

          Could anyone help me with this one?

          • 2. Re: <a4j:poll> always call rich:dataTable value method.
            iabughosh Master

            hello paul,

            this occures because you don't define execute attribute with the right parameters, try this :

            <a4j:poll id="poll"

                                                                          interval="10000"

                                                                          enabled="true"

                                                                          execute="@none"/>

             

            you didn't define execute, it means that the parent of a4j:poll will execute which is in your code is a4j:region, when timing occures a4j:region executes and posts all its data to the server.

             

            ps:you can change execute to define specific components ids to send its data to the server.

             

            regards.

            • 3. Re: <a4j:poll> always call rich:dataTable value method.
              Paul Wicher Newbie

              Hi,

              Thanks for reply. Unfortunately adding execute="@none" didn't help. As I understand a4j:poll in my case shouldn't call any method since it do not reRender any component and none of my components have ajaxRendered atrubute set to true.

              • 4. Re: <a4j:poll> always call rich:dataTable value method.
                iabughosh Master

                try using RichFaces 4.1 final, and use it like this :

                <h:form>

                <a4j:poll id="poll"

                              interval="10000"

                              enabled="true"

                              execute="@none"/>

                 

                regards.

                1 of 1 people found this helpful
                • 5. Re: <a4j:poll> always call rich:dataTable value method.
                  Paul Wicher Newbie

                  I will check this out but for some time I can't migrate to RichFaces 4.1. Any workaround for version 4.0.0.Final ?

                  • 6. Re: <a4j:poll> always call rich:dataTable value method.
                    iabughosh Master

                    i've tested it with RF 4, and execute="@none" solved your problem, please post your full .xhtml page.

                    • 7. Re: <a4j:poll> always call rich:dataTable value method.
                      Paul Wicher Newbie

                      Ok, I checked once again everything. Since I wanted to show that poll do call table value method on every request I removed from it render attribute. In the application this poll will rerender table so I checked this combinations:

                      1. <a4j:poll id="poll" interval="10000" enabled="true" render="tasksTable" execute="@none"/>

                      2. <a4j:poll id="poll" interval="10000" enabled="true" execute="@none"/>

                      3. <a4j:poll id="poll" interval="10000" enabled="true" render="tasksTable">

                      4. <a4j:poll id="poll" interval="10000" enabled="true" />

                       

                       

                      And here are my results:

                      For RichFaces 4.0:

                      1. loadTask called two times per 10 seconds

                      2. loadTask called once per 10 seconds

                      3. loadTask called two times per 10 seconds

                      4. loadTask called once per 10 seconds

                       

                       

                      For richfaces 4.1 in every combination loadTask is being called only once per 10 seconds. Moving to richfaces 4.1  could be acceptable solution since I will be rerendering table.  But I assume that if I would have another table on same page than value method would be called for both tabels even if I do not want this second table to be rerendered.

                       

                       

                      Here is my  full page (there are some irrelevant things, but maybe they turn out to be important so I didn't cut them):

                       

                       

                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                      <html xmlns="http://www.w3.org/1999/xhtml"

                            xmlns:h="http://java.sun.com/jsf/html"

                            xmlns:f="http://java.sun.com/jsf/core"

                            xmlns:rich="http://richfaces.org/rich"

                            xmlns:a4j="http://richfaces.org/a4j"

                            xmlns:ui="http://java.sun.com/jsf/facelets"

                            xmlns:eClaims="http://java.sun.com/jsf/composite/eClaims">

                       

                          <f:view>

                          <h:head></h:head>

                                    <h:body>

                                        <a4j:region >

                                            <a4j:poll id="poll" interval="10000" enabled="true" render="tasksTable" execute="@none"/>

                                        </a4j:region>

                                        <h:form>

                                                  <rich:dataTable

                                                    value="#{pollTestBean.loadTasks()}"

                                                    var="task"

                                                    rows="8"

                                                    rowKeyVar="selected_row"

                                                    styleClass="taskTable"

                                                    rowClass="navTable"

                                                    onrowmouseover="this.style.backgroundColor='#F1F1F1'"

                                                    onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

                                                    id="tasksTable" >

                                                    <f:facet name="noData">

                                                        #{msg.incomingDocumentNothingFound}

                                                    </f:facet>

                                                    <rich:column>

                                                        <f:facet name="header">

                                                            <h:outputLabel value="#{msg.tasksTableExecutionDate}" />

                                                        </f:facet>

                                                        <h:outputText value="#{task.executionDate}" id="taskExecutionDate"/>

                                                    </rich:column>

                                                    <rich:column>

                                                        <f:facet name="header">

                                                            <h:outputLabel value="#{msg.tasksTableName}"/>

                                                        </f:facet>

                                                        <h:outputText value="#{task.businessName}" id="taskName"/>

                                                    </rich:column>

                                                    <f:facet name="footer">

                                                    <h:panelGrid columns="1" style="text-align:center;margin:auto" >

                                                        <rich:dataScroller renderIfSinglePage="true" maxPages="5" fastControls="hide" boundaryControls="auto"/>

                                                    </h:panelGrid>

                                                </f:facet>

                                                </rich:dataTable>

                                                <h:outputText value="#{pollTestBean.fristTask}" />

                                                <a4j:log />

                                      </h:form>

                                    </h:body>

                          </f:view>

                      </html>

                       

                       

                      Thanks for help.

                      • 8. Re: <a4j:poll> always call rich:dataTable value method.
                        iabughosh Master

                        it works fine with me, but i'm wondering how iss your a4j:poll working and it doesn't wrapped by a h:form element ? are using it inside another page ?

                        please open a JIRA request describing your problem.

                         

                        BTW, what is your JSF & AS versions ?

                        • 9. Re: <a4j:poll> always call rich:dataTable value method.
                          Paul Wicher Newbie

                          I am directly opening this page. Maybe You could show me Your testing page so I could try it out?

                          I am using RichFaces 4.0.0.Final and JSF  2.1.1-b04 (Oracle).

                          • 10. Re: <a4j:poll> always call rich:dataTable value method.
                            iabughosh Master

                            PFA.

                             

                            BTW:

                            getGreetings & getAllData methods has also system.out to trace the polling.

                             

                             

                            regards.

                            • 11. Re: <a4j:poll> always call rich:dataTable value method.
                              Paul Wicher Newbie

                              Ibrahim,

                              I changed my page according to what You send me in attachment and value method still being called two times. Here is changed page:

                               

                              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                              <html xmlns="http://www.w3.org/1999/xhtml"

                                    xmlns:h="http://java.sun.com/jsf/html"

                                    xmlns:f="http://java.sun.com/jsf/core"

                                    xmlns:ui="http://java.sun.com/jsf/facelets"

                                    xmlns:rich="http://richfaces.org/rich"

                                    xmlns:a4j="http://richfaces.org/a4j">

                               

                               

                                        <h:head>

                                                  <title>Rich</title>

                                        </h:head>

                                        <h:body>

                                                  <h:form>                                                              

                                                            <rich:panel id="panel" rendered="true">

                                                                      <a4j:poll id="poll" interval="10000" enabled="true" execute="@none" render="extended"/>                                   

                                                                      <rich:extendedDataTable id="extended"

                                                                                                                                  value="#{pollTestBean.loadTasks()}"

                                                                                                                                  var="row">

                                                                                <f:facet name="header">

                                                                                          <h:outputText value="get value from database" />

                                                                                </f:facet>

                                                                                <h:column>

                                                                                          <f:facet name="header">

                                                                                                    <h:outputText value="Column 1" />

                                                                                          </f:facet>

                                                                                          <h:outputText value="#{row.executionDate}" />

                                                                                </h:column>

                                                                                <f:facet name="header">

                                                                                          <h:outputText value="get value from database" />

                                                                                </f:facet>

                                                                                <h:column>

                                                                                          <f:facet name="header">

                                                                                                    <h:outputText value="Column 2" />

                                                                                          </f:facet>

                                                                                          <h:outputText value="#{row.businessName}" />

                                                                                </h:column>

                                                                      </rich:extendedDataTable>

                                                            </rich:panel>

                                                  </h:form>          

                                        </h:body>

                              </html>

                               

                              Can anyone comment on why we get different results?

                              • 12. Re: <a4j:poll> always call rich:dataTable value method.
                                iabughosh Master

                                maybe it is an environment issue, my env :

                                1-JBoss 6.0 Final

                                2-JSF Mojarra 2.0.3 (embedded with AS)

                                3-RF 4.1 Final

                                 

                                what is yours ?

                                • 13. Re: <a4j:poll> always call rich:dataTable value method.
                                  Paul Wicher Newbie

                                  Hi, my configuration:

                                  1- GlassFish Server Open Source Edition 3.1.1 (build 12)

                                  2-JSF  2.1.1-b04 (Oracle JSF Implementation)

                                  3-RichFaces 4.0.0.Final

                                   

                                  And I tested it also with RichFaces 4.1.0.Final with slightly different results (post #7).

                                  I will check it with Your JSF implementation.



                                  • 14. Re: <a4j:poll> always call rich:dataTable value method.
                                    iabughosh Master

                                    if you still have problems please open a JIRA request.

                                    1 2 Previous Next