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

    Avoid calling actionListener

    Jose Miguel Loor Apprentice


      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


            This would be the thing

            <rich:dataTable id="modulosDataTable"
             var="item" cellspacing="0" cellpadding="2"
             <rich:column id="moduleRowColumn" style="width:20px">
             <f:facet name="header"><h:outputText value=" " escape="false"/></f:facet>
             <a4j:commandLink id="editModuleCommandLink"
             actionListener="#{modulosFormasController.selectRowListener}" />
             <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 id="moduleStateColumn">
             <f:facet name="header"><h:outputText value="Estado" escape="false"/></f:facet>
             <h:outputText id="moduleState" value="#{item.estado}" />
             <rich:column id="moduleResponsibleColumn">
             <f:facet name="header"><h:outputText value="Responsable" escape="false"/></f:facet>
             <h:outputText id="moduleResponsible" value="#{item.responsable}" />
             <a4j:support id="moduleSelectRowSupport"
             onsubmit="setSelectedRow(this)" />

            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.