1 Reply Latest reply on Oct 22, 2008 6:34 AM by Konstantin Mishin

    commandButton Outside scrollableDataTable

    Vik Glo Newbie

      Hi All,

      I am to using scrollableDataTable to show data on screen. My problem is when I am trying to have a delete link associated with each row in the table it is calling the method in backing bean and gives me the id of selected row. But when I have only one commandButton outside the scrollableDataTable and select any of the rows in table and then click the button it doesn't get me the id of selected row my code is below

      <rich:scrollableDataTable binding="#{myController.dataTable}" rowKeyVar="rkv" height="100px"
      width="700px" id="contactList" rows="10" columnClasses="col"
      value="#{myController.contacts}" var="contacts">
      <rich:column id="contact">
      <f:facet name="header"><h:outputText styleClass="headerText" value="Contact" /></f:facet>
      <h:outputText value="#{contacts.contact}" />
      <h:inputHidden value="#{contacts.contactId}" />
      <rich:column id="id">
      <f:facet name="header">
      <h:outputText value="ID" />
      <h:commandLink value="Delete" action="#{companyController.deleteContact}" />

      <h:commandButton value="Delete Selected" action="#{myController.deleteContact}" />

      ****MyController Method****
      private HtmlScrollableDataTable dataTable;
      private ContactVO contactVO;
      public String deleteContact() {

      /*The following piece of code works when a commandLink is associated with every row but not with external commandButton*/
      contactVO = (ContactVO) dataTable.getRowData();

      logger.debug("My Id "+contactVO.getContactId());

      return null;

      Please suggest a fix for it.

      Thank you