I have an <a4j:commandLink> in a <rich:datatable>. The same problem applies to <a4j:commandButton> and <a4j:repeat>. The bean action specified was not executed, and the <a4j:actionparam> values were not bound.
For example this was not working:
<a4j:form>
<rich:dataTable id="searchResults" value="#{myBean.searchResults}" var="item">
<rich:column>
<a4j:commandLink value="#{item.code}" action="#{myBean.myAction}"
reRender="myRegion">
<a4j:actionparam name="code" value="#{item.code}"
assignTo="#{myBean.selectedCode}"/>
</a4j:commandLink>
</rich:column>
</rich:dataTable>
</a4j:form>
The region was getting rerendered, but myBean.myAction was not executed.
Then I tried moving the <a4j:form> inside the table, so there was a form on each row:
<rich:dataTable id="searchResults" value="#{myBean.searchResults}" var="item">
<rich:column>
<a4j:form>
<a4j:commandLink value="#{item.code}" action="#{myBean.myAction}"
reRender="myRegion">
<a4j:actionparam name="code" value="#{item.code}"
assignTo="#{myBean.selectedCode}"/>
</a4j:commandLink>
</a4j:form>
</rich:column>
</rich:dataTable>
This seemed to work for the first row, but not any subsequent ones.
The answer seems to be to base the dataTable on a session scoped bean. I didn’t want my orignal bean session scoped, so I split it into two like this:
<rich:dataTable id="searchResults" value="#{mySessionBean.searchResults}" var="item">
<rich:column>
<a4j:form>
<a4j:commandLink value="#{item.code}" action="#{myBean.myAction}"
reRender="myRegion">
<a4j:actionparam name="code" value="#{item.code}"
assignTo="#{myBean.selectedCode}"/>
</a4j:commandLink>
</a4j:form>
</rich:column>
</rich:dataTable>
And it works. The actions are still carried out on my request bean as I wanted and I just have to be careful about how I update the session bean.
