6 Replies Latest reply on Jan 29, 2009 7:33 PM by nbelaevski

    Assigning different select options to InPlaceSelect componen

    java4me

      I have an application which displays data in different columns. The cells are editable and changes can be persisted. I am using inPlaceEdit for this.

      There is one column which uses inPlaceSelect component. We provide options to the user when he double clicks a cell in this column. These options remain same for all the cells in the column. I require to show different options based on the rows.

      We provide the options at the time of creation of column model.
      Is it possible to have different options for different cells?

      If somebody can share his/her information or experience on this it shall be highly appreciated.

        • 1. Re: Assigning different select options to InPlaceSelect comp
          java4me

          To put it clear, I am giving one example. Here is the table I wanted to generate.

          Region Countries
          Europe England{England,France,Germany}
          Asia Japan{China,Japan,India}
          


          In the above table, we have two columns region and countries. Based on value in region, the options in countries must be popuplated.

          I am using scrollable data table. Please let me know how I can provide different set of options for different rows.

          • 2. Re: Assigning different select options to InPlaceSelect comp

            You can use a4j:support with onchange event to realize this. The reRender attribute can refresh your second inplaceSelect.
            More information about this here:
            http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf?tab=selects&cid=979604

            • 3. Re: Assigning different select options to InPlaceSelect comp
              java4me

              Thanks for your thoughts, but I am not changing any value in region row. It is a data model getting created for scrollable data model. The region column is simply display column and countries column should be renderred with different set of values.

              FYI, I am creating table columns using HtmlColumn. For this component we can add one child which is HtmlInplaceSelect.

              Is it possible to have cell renderer which will be called by Richfaces before rendering each cell with row and columns as arguments?

              • 4. Re: Assigning different select options to InPlaceSelect comp
                nbelaevski

                Hi,

                I do not see any problem in binding in-place select components in the second column to the row variable. E.g. like this:

                <rich:dataTable var="item" ...>
                 <rich:column>
                 <rich:inplaceSelect>
                 <f:selectItems value="#{item.selelctItems}" />
                
                ...


                • 5. Re: Assigning different select options to InPlaceSelect comp
                  java4me

                  Thanks for your replies.

                  Hi nbelaevski

                  I am creating the datamodel and columnmodel for the table dynamically[java code] rather than a jsp. The number of columns, content depends upon DB entries.

                  Here is the code snippet of my jsp.

                  <rich:scrollableDataTable
                   binding="#{bean.searchHtmlScrollableDataTable}"
                   id="searchTable" var="searchTableData" rowKeyVar="key"
                   hideWhenScrolling="true"
                   value="#{bean.dataList}">
                  </rich:scrollableDataTable>
                  
                  

                  I use list of object arrays to populate each row of the table.

                  So using the value of 'var' property of the table doesnt help in here as the var will be mapped to an object array and a method to populate the UIselectItems cannot be implemented.

                  Is there any other way around for it?
                  Also i will like to know if the renderer for the InPlaceEdit can be overriden for this?

                  • 6. Re: Assigning different select options to InPlaceSelect comp
                    nbelaevski

                    Not a problem, use the following expression:

                    <f:selectItems value="#{item[x].selelctItems}" />
                    where "x" is column index.

                    For the question on renderer: renderer is not the only object that needs correct information about values, component itself may need this also.

                    BTW, have you tried rich:columns?