4 Replies Latest reply on Jan 14, 2009 12:51 PM by Valerie Griffin

    extendedDataTable selection property

    Valerie Griffin Newbie

      How is the selection property supposed to work? It says that the value is supposed to evaluate to ...model.Selection, but there's no documentation for that interface or anything that extends it.

      An example includes what looks like a call to a getter/setter in the backing bean, but there's no info on the method.

      I grabbed the source where I found Selection and SimpleSelection. I tried using SimpleSelection, but it didn't seem to get updated.

      Then, I copied SimpleSelection into my code and instrumented it with println. None of the add or remove methods were called.

      I'm using Seam 2.1 and 3.3 GA for RichFaces.

        • 1. Re: extendedDataTable selection property
          Valerie Griffin Newbie

          I'd also like to know how to use the rowKwyVar and the ActiveRowKey.

          Part of what I'm trying to do is feed ajaxKeys from the selection. If I use ajaxKeys, how do I tell it to render the entire table?

          • 2. Re: extendedDataTable selection property
            Thai Dang Vu Apprentice

             

            "vgriffin" wrote:
            How is the selection property supposed to work? It says that the value is supposed to evaluate to ...model.Selection, but there's no documentation for that interface or anything that extends it.

            An example includes what looks like a call to a getter/setter in the backing bean, but there's no info on the method.

            I grabbed the source where I found Selection and SimpleSelection. I tried using SimpleSelection, but it didn't seem to get updated.

            Then, I copied SimpleSelection into my code and instrumented it with println. None of the add or remove methods were called.

            I'm using Seam 2.1 and 3.3 GA for RichFaces.


            I don't know about rowKwyVar and ActiveRowKey. If you know about them later on, please share your knowledge.

            About selection (by the way, if you're using Seam, why do you need this? I don't know Seam much, but I heard that Seam allows you to call a server method and pass something as an argument. In this case, that "something" is the row you click), this is how it works:
            - xhtml
            <rich:extendedDataTable value="#{bean.cars}" var="car" binding="#{bean.extdt}" selection="#{bean.selection}" selectionMode="single" ...>
            ...
            </rich:extendedDataTable>

            selection mode can be single or multiple but not none. Suppose that there's method named selectCar in the jsf-managed bean where you want to know which row is selected. If you want to call this method by clicking on a link/button then go with <a4j:commandButton action="#{bean.selectCar}" .../>. If you want to call that method when you click on a row, then insert this inside the <rich:extendedDataTable>:
            <a4j:support event="onRowClick" oncomplete="selectCar();" />
            and insert this outside the <rich:extendedDataTable>
            <a4j:jsFunction name="selectCar" action="#{bean.selectCar}" reRender="..."/>

            -JSF-managed bean
            public class Bean {
             private HtmlExtendedDataTable extdt;
             private Selection selection;
             private void selectCar() {
             Iterator<Object> iterator = selection.getKeys();
             while (iterator.hasNext()) {
             Object key = iterator.next();
             extdt.setRowKey(key);
             Car selectedCar = (Car) extdt.getRowData();
             }
             }
             ... getters & setters...
            }

            Hope that helps.

            • 3. Re: extendedDataTable selection property
              Valerie Griffin Newbie

              Seam's great at passing stuff to my code. I really like using it. One of the things I'm trying to do is rerender only the row that's been changed by using the key value to set ajaxKeys for the table. The user can make an edit in the table values and I can mark the row as having been changed by rerendering just that row.

              The code you show with the getKeys is approximately what I've been trying to coax rechFaces into invoking, but it's not going there.

              I don't think I have to use the a4j:jsfunction entry. I've been using the action property of a4j:support with other components (lots and lots or other components....). I'll try using onRowClick and post the result.

              • 4. Re: extendedDataTable selection property
                Valerie Griffin Newbie

                Using onRowClick didn't advance the cause.

                But the suggestion provided the necessary inspiration.

                Adding:

                <a:support event="onselectionchange" action="#myHome.procSelection}" bypassUpdates="false" ajaxSingle="true">
                </a:support>

                works!!!!!

                Stuff happens in the order:

                I click on the dropdown in my table row

                myHome.getSelection is called twice
                selection.clear is called
                selection.addKey is called
                myHome.setSelection is called with the row set
                procSelection is called
                getAjaxKeys is called

                My table uses single-row selection.