11 Replies Latest reply on Mar 8, 2011 11:14 PM by Murali Krishna

    ExtendedDataTable - Selected Row

    Paul Baker Apprentice

      I would like to rerender a component when an ExtendedDataTable row is selected. The rerendered component will contain additional information about the selected row.

      How can I do this? Please provide an example if possible.

      Thanks,

      Paul

        • 1. Re: ExtendedDataTable - Selected Row
          Ilya Shaikovsky Master

          Use onselectionchange attribute with a4j:support. And manage selection in the same way that shown at at livedemo scrollableDataTable example.

          • 2. Re: ExtendedDataTable - Selected Row
            Paul Baker Apprentice

             

            "ilya_shaikovsky" wrote:
            Use onselectionchange attribute with a4j:support. And manage selection in the same way that shown at at livedemo scrollableDataTable example.


            Works perfectly!!!! Thanks for all your hard work!!!!

            • 3. Re: ExtendedDataTable - Selected Row
              Ilya Shaikovsky Master

              This is community contributed component. So, thanks all of you for your feedbacks and efforts also ;)

              • 4. Re: ExtendedDataTable - Selected Row
                Ingo Jobling Master

                Hi, As suggested above, I am trying to use, for the extendedDataTable,

                <a4j:support event="onselectionchange" action="{bean.onSelectionChange()}" />


                In Internet Explorer, it generates an Ajax request, but the bean method is not called.

                In Firefox, it produces event is not defined.

                I have two questions:

                Is this is an IE only event, as described here: http://msdn.microsoft.com/en-us/library/ms537845(VS.85).aspx ?

                Does the action attribute in a4j:support work for this version of the extendedDataTable?

                Environnement:

                Richfaces 3.2.2
                JSF 1.2.04
                Seam 2.01 SP1


                Any help would be greatly appreciated.

                Thanks in advance!




                • 5. Re: ExtendedDataTable - Selected Row
                  Paul Baker Apprentice

                  FYI, I did it this way...

                  <h:panelGrid columns="2">
                   <h:panelGroup>
                   <rich:spacer height="5" />
                   <rich:extendedDataTable id="revision"
                   binding="#{docRevisionController.table}"
                   selection="#{docRevisionController.selection}"
                   value="#{docRevisionController.value}" var="item" first="0"
                   rows="20" selectionMode="single" width="700px"
                   onselectionchange="updateRow()"
                   columnClasses="tableTextInputCol" bgcolor="#CAE1F8"
                   cellpadding="0" cellspacing="0">
                   <rich:column id="docIssueNum">
                   <f:facet name="header">
                   <h:outputText value="Issue Number" />
                   </f:facet>
                   <h:inputText value="#{item.docIssueNum}"
                   styleClass="tableTextInput" size="12" />
                   </rich:column>
                  
                  


                  ...
                  ...

                  <a4j:jsFunction name="updateRow" reRender="rowControl">
                  </a4j:jsFunction>
                  


                  • 6. Re: ExtendedDataTable - Selected Row
                    Ingo Jobling Master

                    Hi, thanks very much for your reply!

                    I am glad that you were able to get it working.

                    Do you think that I would be able to adapt your example to call a method in the backing bean (Seam component) ?

                    Regards!

                    • 7. Re: ExtendedDataTable - Selected Row
                      Piotr Kawiak Newbie

                       

                      "joblini" wrote:

                      I have two questions:

                      Is this is an IE only event, as described here: http://msdn.microsoft.com/en-us/library/ms537845(VS.85).aspx ?

                      Does the action attribute in a4j:support work for this version of the extendedDataTable?


                      As for now a4j:support onsecectionchanged is not working with extDt, I am investigating that bug and update this topic as soon as I'll find cause. Pbaker had found a workaround but we are definitely going to make it work with a4j:support.

                      • 8. Re: ExtendedDataTable - Selected Row
                        Ingo Jobling Master

                        Hi, thanks for the quick reply!

                        By using Pbaker's workaround, I am able to invoke a method on the backing bean

                        <rich:extendedDataTable id="productionsTable" onselectionchange="onSelectionChange()"
                        
                        
                        <a4j:jsFunction name="onSelectionChange" action="#{bean.onSelectionChange()}" >
                        </a4j:jsFunction>
                        


                        But I can't figure out how to identify which row has been selected.
                        I tried using @DataModelSelection but it always points to the first row in the table.

                        This is how I am doing it for now:

                        <rich:extendedDataTable id="productionsTable" var="row"
                        
                        <a4j:support event="onRowDblClick" action="#{bean.onRowDblClick(row)}"/>
                        
                        



                        • 9. Re: ExtendedDataTable - Selected Row
                          Paul Baker Apprentice

                          I identify the row in the backing bean...

                          Set "selection"

                          <a4j:form id="revisionForm">
                           <center>
                           <h:panelGrid columns="2">
                           <h:panelGroup>
                           <rich:spacer height="5" />
                           <rich:extendedDataTable id="revision"
                           binding="#{docRevisionController.table}"
                           selection="#{docRevisionController.selection}"
                           value="#{docRevisionController.value}" var="item" first="0"
                           rows="20" selectionMode="single" width="700px"
                           onselectionchange="updateRow()"
                           columnClasses="tableTextInputCol" bgcolor="#CAE1F8"
                           cellpadding="0" cellspacing="0">



                          Then access the selection in the backing bean...

                          public abstract class ExtendedTableRowSelection extends BaseController {
                           private UIExtendedDataTable table;
                           private SimpleSelection selection = new SimpleSelection();
                           private List<Object> value;
                          
                           /**
                           * @return the rowNumber
                           */
                           public String getSelectedRowIdentifier() {
                           int i = 0;
                           try {
                           i = getSelectedRowIndex();
                           } catch (NoRowSelected e) {
                           return "No Row Selected";
                           }
                          
                           if (isBlankRow(i)) {
                           return "Blank Row Selected";
                           } else {
                           return getRowIdentifier(i);
                           }
                           }
                          
                           public int getSelectedRowIndex() throws NoRowSelected {
                          
                           if (selection == null || table == null)
                           throw new NoRowSelected();
                          
                           Iterator<Object> iterator = getSelection().getKeys();
                           while (iterator.hasNext()) {
                           Object key = iterator.next();
                           table.setRowKey(key);
                           if (table.isRowAvailable()) {
                           return (Integer) key;
                           }
                           break;
                           }
                           throw new NoRowSelected();
                           }


                          • 10. Re: ExtendedDataTable - Selected Row
                            Piotr Kawiak Newbie

                            The a4j:support onselectionchange should now work with the most fresh version of extDt. Please check out extendedDataTable-sample project, there you can find complete working example of selection handling (using SimpleSelection and ExtendedTableDataModel).

                            • 11. Re: ExtendedDataTable - Selected Row
                              Murali Krishna Newbie

                              Hi all,

                               

                              we are still facing the same issue with IE 7.

                               

                              Does the action attribute in a4j:support work for this version of the extendedDataTable?

                               

                              using Pbaker's workaround it works fine. But richfaces demo it works in IE 7. am just confused how it works in richfaces demo but not in my application.

                               

                              Environment:

                                   Rich Faces : 3.3.3.Final

                                   JSF: 1.2

                                   Browser IE 7 & 8

                               

                              Thanks,

                              Murali