3 Replies Latest reply on Feb 14, 2011 8:16 AM by Bronislav Pechmik

    a4j:poll updating table in which is a4j:commandLink is placed

    Bronislav Pechmik Newbie

      I have such table.

       

      <!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:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich">
          <link rel="stylesheet" type="text/css"
                href="${request.contextPath}/css.css" />
          <body>    
                  <h:panelGroup>          
                        <a4j:form eventsQueue="TradesFormQue">
                            
                             <a4j:poll limitToList="true" immediate="true" id="poll" interval="2000"
                                    action="#{TradersSymbolStats.reload}"
                                    reRender="myId,poll"/>                       
                              <rich:dataTable value="#{TradersSymbolStats.data}" var="repeater" id= "myId" align = "top" >
                                      <rich:column   style="text-align:right" width="150">
                                               <f:facet name="header">
                                                   <h:outputText value="Currency" />
                                               </f:facet>
                                          <a4j:commandLink eventsQueue="TradesFormLinkQue" value="#{repeater.name}"  action = "CurrencyTrades" >
                                                    <f:setPropertyActionListener value="#{repeater.name}"
                                                          target="#{TradersSymbolStats.currency}"/>
                                               </a4j:commandLink>
                                     </rich:column>
                                     <rich:column   style="text-align:right" width="150">
                                               <f:facet name="header">
                                                   <h:outputText value="Total Buy" />
                                               </f:facet>
                                               <h:outputText value="#{repeater.buy}" style="text-align:right"  >
                                                    <f:convertNumber type="number" groupingUsed="true" locale="en" />
                                               </h:outputText>
                                     </rich:column>                                                
                                </rich:dataTable>
                          </a4j:form>
                    </h:panelGroup>   
          </body>
      </html>

       

       

      It is updated by a4j:poll to show some new information to user. When the user is clicking commandLink I need to redirect to another page. But it needs to click for about five to go to another page. When I removes a4j:poll every thing works fine. How it can be fixed with a4j:poll?

        • 1. a4j:poll updating table in which is a4j:commandLink is placed
          Ilya Sorokoumov Master

          Take a look at this link:

          http://community.jboss.org/thread/148465?tstart=1

          I guess you can stop a4j:poll on a click event for your link.

          • 2. Re: a4j:poll updating table in which is a4j:commandLink is placed
            Bronislav Pechmik Newbie

            I tried this, but it didn`t helped.

            <?xml version='1.0' encoding='UTF-8' ?>
            <!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:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich">
                <link rel="stylesheet" type="text/css"
                      href="${request.contextPath}/css.css" />    
                <body>  
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" border="0"
                                 style="vertical-align:text-top;text-align:right;"
                                 columnClasses="cols,cols" >
                        <h:panelGroup style="vertical-align:text-top;" >
                            <ui:include src="/leftmenu.xhtml"/>
                        </h:panelGroup>
                        <h:panelGroup>                 
                              <a4j:form id="tadersid" >
            
                                   <a4j:poll limitToList="true" immediate="true" id="poll" interval="2000"
                                          action="#{TradersSymbolStats.reload}"
                                          reRender="poll,myId"/>
            
                                    <rich:dataTable value="#{TradersSymbolStats.data}" var="repeater" id= "myId" align = "top" >
                                            <rich:column   style="text-align:right" width="150">
                                                     <f:facet name="header">
                                                         <h:outputText value="Currency" />
                                                     </f:facet>
                                                <a4j:commandLink
                                                          value="#{repeater.name}"
                                                          onclick="A4J.AJAX.StopPoll('#{rich:clientId('poll')}');"
                                                          action = "CurrencyTrades" >
                                                          <f:setPropertyActionListener value="#{repeater.name}"
                                                                target="#{TradersSymbolStats.currency}"/>
                                                     </a4j:commandLink>
                                           </rich:column>
                                           <rich:column   style="text-align:right" width="150">
                                                     <f:facet name="header">
                                                         <h:outputText value="Total Buy" />
                                                     </f:facet>
                                                     <h:outputText value="#{repeater.buy}" style="text-align:right"  >
                                                          <f:convertNumber type="number" groupingUsed="true" locale="en" />
                                                     </h:outputText>
                                           </rich:column>                              
                                      </rich:dataTable>
                                </a4j:form>
                          </h:panelGroup>
                     </h:panelGrid>     
                </body>
            </html>