1 2 Previous Next 17 Replies Latest reply on Feb 3, 2011 10:02 AM by niknik77771

    ExtandedDataTable: rowKey

    niknik77771

      What is it? Why in showcase ExtandedDataTable example this key bacup and after restore to initial state?

        • 1. ExtandedDataTable: rowKey
          ilya40umov

          Could you describe your question?

          There are three rowKey like attributes for ExtandedDataTable :

          activeRowKeyfalsefalsejavax.el.ValueExpression
          (must evaluate to java.lang.Object)
          Request scope attribute under which the activeRowKey will be accessible
          rowKeyConverterfalsefalsejavax.el.ValueExpression
          (must evaluate tojavax.faces.convert.Converter)
          Converter for a row key object

           

          rowKeyVarfalsefalsejavax.el.ValueExpression
          (must evaluate to java.lang.String)
          The attribute provides access to a row key in a Request scope
          • 2. ExtandedDataTable: rowKey
            niknik77771

            My actual problem that after I remove selected row from extendedDataTable selection still exists on another row. If I add rows to extandedDataTable and after remove first row it cause unpredictable behavior of my bean. Suspicions is that it is because of a state saving. So, I decided to use backing bean and to control extendedDataTable programmatically, I saw example code in richfaces-showcase .

             

            public void selectionListener(AjaxBehaviorEvent event){

                    UIExtendedDataTable dataTable = (UIExtendedDataTable)event.getComponent();

                    Object originalKey = dataTable.getRowKey();

                    selectionItems.clear();

                    for (Object selectionKey: selection) {

                        dataTable.setRowKey(selectionKey);

                        if (dataTable.isRowAvailable()){

                            selectionItems.add((InventoryItem)dataTable.getRowData());

                        }

                    }

                    dataTable.setRowKey(originalKey);

                }

             

            I mean this rowKey. Where are tables you listed from?

            • 3. ExtandedDataTable: rowKey
              ilya40umov
              • 4. ExtandedDataTable: rowKey
                niknik77771

                Is it correct for version 4?

                • 5. ExtandedDataTable: rowKey
                  jbalunas

                  Hi Ara,

                   

                  You're seeing royKey in RF 4.0?  If so that is probably a cut/paste error.  We'll take a look.

                   

                  Thanks,

                  Jay

                  • 6. ExtandedDataTable: rowKey
                    niknik77771

                    Please look to code Jay. I speak about UIExtendedDataTable#getRowKey()

                    • 7. ExtandedDataTable: rowKey
                      ilya_shaikovsky

                      please describe your original problem in more details with code samples.

                       

                      I'm using that code because it's needed to restore original component rowKey back after its modifications from actions/listeners code. In other case problems with table encoding, client Id's and so on could appear.

                      • 8. ExtandedDataTable: rowKey
                        niknik77771

                        Work in progress

                        • 9. ExtandedDataTable: rowKey
                          niknik77771

                          But Ilya, what is rowKey?!

                          • 10. ExtandedDataTable: rowKey
                            niknik77771

                            And why do you need restore it?

                            • 11. ExtandedDataTable: rowKey
                              nbelaevski

                              Hi,

                               

                              Row key is the locator object to identify particular object in the model (e.g. number of item in the sequential model such as list or path to the tree node). Model operates over these objects to handle data; iterative components use row keys to generate client id when inside iteration. 

                               

                              As the simplest sequential models available in JSF generate positional keys, they can fail to identify the row when the list changes (items added or removed). To support such use case properly, a custom model with support for more persistent keys (like DB ID) should be provided to the table.

                               

                              Restoring row key after modification is there to keep internal component state consistent. For example, in JSF 2.0, iteration components embed row identifier into the clientId, so when you add table with row identifier set for Ajax rendering, this won't work.

                              1 of 1 people found this helpful
                              • 12. ExtandedDataTable: rowKey
                                niknik77771

                                Thank you Nick for this comprehensive answer. I think that is a reason of my initial problem. How to provide my own row keys to extandedDataTable to delete and add after?

                                • 13. ExtandedDataTable: rowKey
                                  nbelaevski

                                  You should extend org.ajax4jsf.model.ExtendedDataModel and do the processing here. Some examples of customized models are available at 3.x demo.

                                  • 14. ExtandedDataTable: rowKey
                                    niknik77771

                                    To complex for just removing and inserting rows. I try to do it in non ajax way. Anyway thank you very much

                                    1 2 Previous Next