1 Reply Latest reply on Aug 15, 2007 7:09 PM by pdpantages

    A4J:commandButton inside of table updated via A4J:poll

    megardi

      We are trying to use A4J command buttons in a data table to update another region on the page. The data table items are constantly updated via an A4J poll. The problem is that the button will not work on items that have been updated on the page via AJAX (the actionListener doesn't fire). If the page is reloaded, the button works as expected. I understand that there is a discrepancy here between the DOM tree on the browser JSFs view of the page that is probably causing this. Is there any way of accomplishing what we are trying to do here?

      This is basically the code we have:


      <a4j:region>
      <h:dataTable id="itemList" var="item" value="#{myBean.items}">
      <h:column>
      <a4j:commandButton id="EditCheck" eventsQueue="Q1" reRender="EditLayer" actionListener="#{myBean.editItem}"/>
      </h:column>
      <h:column>
      <h:outputText value="#{item.name}"/>
      </h:column>
      </h:dataTable>
      <a4j:poll interval="5000" eventsQueue="Q1" reRender="itemList" actionListener="#{myBean.refreshList}"/>
      </a4j:region>

      <a4j:region>
      <h:panelGrid id="EditLayer">
      <h:outputText value="#{selItem.name}"/>
      <h:outputText value="#{selItem.value1}"/>
      <h:outputText value="#{selItem.value2}"/>
      </h:panelGrid>
      </a4j:region>

        • 1. Re: A4J:commandButton inside of table updated via A4J:poll
          pdpantages

          Hi megardi,

          I have done something similar, but not exactly what you are doing.

          - I am using tomahawk's t:dataTable

          - I put my table inside an a4j:outputPanel, and use this component's ID for the reRenderList, instead of the dataTableId. I would try this for both your table and EditList.

          - I started using a4j:outputPanel for all my re-rendering, as early on I had problems using the target component ids. (I ran into this back in a4j version 1.0.2 or so; Since a4j:outputPanel works for me, I continue to use it)

          - I also have a a4j:region around my poller, but I use renderRegionOnly=false. I found that my renderList was not being updated, when outside the region. You might need this to get the "EditLayer" to rerender when the button is pressed.

          - Also, I use action="#{...}" instead of actionListener, as you are. I am a bit of a novice in this area and don't really know the significance of this difference.

          One of my pollers is:

           <ui:define name="ui_a4j_poll">
           <a4j:region renderRegionOnly="false">
           <a4j:poll
           id="subnetTreePoller"
           action="#{login.checkLoggedin}"
           interval="#{serviceAlarmMgmt.ajaxPollInterval}"
           enabled="true"
           eventsQueue="subnetTreePollerQueue"
           reRender="#{serviceAlarmMgmt.ajaxRenderList}">
           </a4j:poll>
           </a4j:region>
           </ui:define>
          


          Anyway, I find that this works very well for me.

          PdP