3 Replies Latest reply on Jun 22, 2007 5:09 PM by Sergey Smirnov

    Avoid calling actionListener

    Jose Miguel Loor Apprentice

      Hi

      I have a dataTable with an <a4j:support> that triggers an actionListener every time a row is clicked in the dataTable; that part is working ok

      Now, in the same table i have an a4j:commandLink that uses the same actionListener but my problem is that the actionListner is being called two times: one for the a4j:support and one for the a4j:commandLink

      How can i avoid this behaviour and control that when the link is clicked, the listener is not called for the row selection ??

      thanks a lot

        • 1. Re: Avoid calling actionListener
          Sergey Smirnov Master

          could you provide a code snippet for what you have, please.

          • 2. Re: Avoid calling actionListener
            Jose Miguel Loor Apprentice

            Hi

            This would be the thing

            <rich:dataTable id="modulosDataTable"
             binding="#{modulosFormasController.modulosDataTable}"
             value="#{modulosFormasDataManager.modulos}"
             var="item" cellspacing="0" cellpadding="2"
             styleClass="cb-rich-table"
             headerClass="headerCell"
             columnClasses="headerCell,dataCell,dataCell,dataCell,dataCell,dataCell,dataCell"
             rowKeyVar="row">
             <rich:column id="moduleRowColumn" style="width:20px">
             <f:facet name="header"><h:outputText value=" " escape="false"/></f:facet>
             <a4j:commandLink id="editModuleCommandLink"
             value="#{row+1}"
             action="moduleForm"
             actionListener="#{modulosFormasController.selectRowListener}" />
             </rich:column>
             <rich:column id="moduleNameColumn">
             <f:facet name="header"><h:outputText value="Módulo" escape="false"/></f:facet>
             <h:outputText id="moduleName" value="#{item.nombre}" />
             </rich:column>
             <rich:column id="moduleStateColumn">
             <f:facet name="header"><h:outputText value="Estado" escape="false"/></f:facet>
             <h:outputText id="moduleState" value="#{item.estado}" />
             </rich:column>
             <rich:column id="moduleResponsibleColumn">
             <f:facet name="header"><h:outputText value="Responsable" escape="false"/></f:facet>
             <h:outputText id="moduleResponsible" value="#{item.responsable}" />
             </rich:column>
             <a4j:support id="moduleSelectRowSupport"
             event="onRowClick"
             data="#{item.modulo}"
             actionListener="#{modulosFormasController.selectRowListener}"
             onsubmit="setSelectedRow(this)" />
            </rich:dataTable>
            
            


            All of this is inside a a4j:form. Before that i tried with a normal h:form but neither way gave me the result i wanted

            As you see the table has the a4j:support called moduleSelectRowSupport wich calls the selectRowListener method. Also the a4j:commandLink called editModuleCommandLink calls the same selectRowListener method.

            What i need is that when i click in the a4j:commandLink, the listener for the a4j:support gets ignored

            Thanks a lot

            • 3. Re: Avoid calling actionListener
              Sergey Smirnov Master

              I guess it is not an ajax problem, because even without any ajax components you will have two javascript events invoked. This issue should be resolved on the client level.

              P.S. I see action="moduleForm" in your code. If you have a navigation rule for it, the whole page will be refreshed instead of partual ajax response. Also, if this rule have no , the memory leak might happen. So, be careful there.