1 Reply Latest reply on Sep 4, 2008 2:49 AM by btl_ayd

    rich:datatable, a4j:support and onRowClick

    geggle

      I'm attempting to do a simple list and detail display model with the richfaces data table.

      From what I can tell, I should use a <a4j:support.../> tag within the <rich:dataTable .../> tag to trigger the selection on the onRowClick event.

      However, my action handler never gets called, and I can't work out why.

      I have a page of the following form:

      <a4j:form id="contactForm" ajaxSubmit="true">
       <rich:panel>
       <rich:dataTable
       id="otherPartyList"
       rows="10"
       width="100%"
       var="party"
       rowKeyVar="row"
       value="#{contact.interestedParties}"
       binding="#{contact.interestedPartiesTable}">
       <a4j:support event="onRowClick" action="#{contact.selectRow}" reRender="selectedOtherPartyFragment"/>
       <rich:column sortable="false">
       <f:facet name="header">
       <f:verbatim>Row</f:verbatim>
       </f:facet>
       <h:outputText value="#{row}" />
       </rich:column>
       <rich:column sortBy="#{party.title}">
       <f:facet name="header">
       <f:verbatim>Title</f:verbatim>
       </f:facet>
       <h:outputText value="#{party.title}" />
       </rich:column>
       <rich:column sortBy="#{party.name}">
       <f:facet name="header">
       <f:verbatim>Name</f:verbatim>
       </f:facet>
       <h:outputText value="#{party.name}" />
       </rich:column>
       </rich:dataTable>
      
       <a4j:outputPanel id="selectedOtherPartyFragment">
       <f:subview id="detail" rendered="#{contact.selectedParty != null}">
       <rich:spacer height="10px"/>
       <h:outputText value="#{party.title}" />
       <h:outputText value="#{party.name}" />
       </f:subview>
       </a4j:outputPanel>
       </rich:panel>
      </a4j:form>
      


      and my backing bean (contact) is of this form:
      package com.workcover.clw.noc.web.managedBean;
      
      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.List;
      
      import org.richfaces.component.html.HtmlDataTable;
      
      import com.workcover.clw.noc.domain.InterestedPartyDetails;
      
      public class ContactTab implements Serializable {
       /** Version ID */
       private static final long serialVersionUID = 4260048709217435243L;
       private List<InterestedPartyDetails> interestedParties;
       private InterestedPartyDetails selectedRow;
       private transient HtmlDataTable interestedPartiesTable;
      
       public ContactTab() {
       ... set up some test InterestedPartyDetails objects in interestedParties ...
       }
      
       public List<InterestedPartyDetails> getInterestedParties() {
       return interestedParties;
       }
      
       public HtmlDataTable getInterestedPartiesTable() {
       return interestedPartiesTable;
       }
      
       public void setInterestedPartiesTable(HtmlDataTable interestedPartiesTable) {
       this.interestedPartiesTable = interestedPartiesTable;
       }
      
       public String selectRow() {
       Object obj = getInterestedPartiesTable().getRowData();
       selectedRow = (InterestedPartyDetails) obj;
       return null;
       }
      
       public InterestedPartyDetails getSelectedParty() {
       return selectedRow;
       }
      }
      


      Does anyone have some ideas as to what I am doing wrong? I can't imagine that such a simple interaction can be difficult, but I'm stumped.