3 Replies Latest reply on May 27, 2009 1:46 PM by David Fuchs

    Why rich:extendedDataTable state depends on where a commandB

    David Fuchs Newbie


      I'm trying to figure out why clicking an a4j:commandButton causes the rich:extendedDataTable to have different state whether the button was clicked from a row in the table or somewhere outside the table. Unfortunately, I don't have enough experience with JSF or Richfaces to find the solution myself.

      The buttons inside and outside the table are identical (except for id, of course). All they do is declare a value and an action - the action prints some debug info about the selected row to the log, as such:

      When I select a row and press the button *outside* the table, 'getRowIndex()' throws javax.faces.model.NoRowAvailableException. However, when I select a row and press the button for that row inside the table, the 'getRowIndex()' method of the table returns a valid integer.

      What is the reason for this behavior? What is going on behind the scenes to have the table set the active row when I press a button inside the table? Better yet, how do I go about figuring this out myself?


        • 1. Re: Why rich:extendedDataTable state depends on where a comm
          David Fuchs Newbie

          Apologies for the long title. Original title was:

          Why rich:extendedDataTable state depends on where a commandButton was clicked.


          • 3. Re: Why rich:extendedDataTable state depends on where a comm
            David Fuchs Newbie

            Here's the code, thanks! Using Richfaces 3.3.0.GA. Please let me know if I can provide anything else. Again, there's something special about this button being inside a column that causes the table to have a valid rowIndex, I'm just not sure what this process is.

            JSF Page:

            <rich:extendedDataTable id="searchResults" value="#{searchBean.items}" var="item" binding="#{searchBean.table}">
             <rich:column id="colSubmit" width="100" label="Submit">
             <a4j:commandButton value="Submit" id="submitButton1" action="#{searchBean.logDebugInfo}" />
            <br clear="all" />
            <a4j:commandButton value="Submit" id="submitButton2" action="#{searchBean.logDebugInfo}" />


            Java Code:
            public void logDebugInfo() {
             SearchItem selectedItem = (SearchItem)table.getRowData();
             logger.debug(String.format("Selected Item: %s", selectedItem.toString()));

            The call to table.getRowIndex() always succeeds when invoked through submitButton1. However, the call always throws javax.faces.model.NoRowAvailableException when submitButton2 is invoked, whether or not a row is selected. I've also tried set the managed bean to session scope just to see what would happen, but the results are the same.

            Looking forward to learning how to diagnose these things, thanks!