3 Replies Latest reply on Aug 3, 2011 4:49 PM by Brian Leathem

    Problem creating SelectItems

    Brian Leathem Master

      For the orderingList, I prototyped the functionality using a nested f:selectItems component, as in:

      [example 1]:
                  <rich-input:orderingList id="orderingList" value="#{richBean.values}">
                      <f:selectItems value="#{richBean.values}" var="item"  itemValue="#{item}" itemLabel="#{item.title}" />
                      <f:converter converterId="EntityBeanConverter" />
                  </rich-input:orderingList>
      

       

      Now that I have that working, I want to move the item definition into the ordering list itself as in:

      [example 2]:
                  <rich-input:orderingList id="orderingList" value="#{richBean.values}" itemValues="#{richBean.values}" var="item" itemValue="#{item}" itemLabel="#{item.title}" >
                      <f:converter converterId="EntityBeanConverter" />
                  </rich-input:orderingList>
      

      (Don't worry, the itemValues is there temporarily as I get this working!)

       

      Now to generate the selectItem objects, I wanted to re-use as much of the existing code as possible, so I created an interface called "SelectItemsInterface" (for lack of a better name), and adapted the SelectUtils class to add the component itself to the iterator if the component implements this interface.  This is done as follows:

          public static Iterator<SelectItem> getSelectItems(FacesContext context, UIComponent component) {
              Iterator<UIComponent> children = component.getChildren().iterator();
              if (component instanceof SelectItemsInterface) {
                  Iterator<UIComponent> self = Iterators.singletonIterator(component);
                  children = Iterators.concat(self, children);
              }
              Iterator<SelectItem> iterator = new SelectItemsIterator(context, children);
              return iterator;
          }
      

       

      The process for generating the selectItems from the orderingList tag is almost identical to the process of creating selectItems from the f:selectItems tag, except the values come from the itemValues tag for now.

       

      This works well, in that the selectItem objects are created with the iterator, and I'm able to render the page.

       

      The problem comes about when I submit the page.  In [example 1] above everything works as expected.  However, in [example 2] the setter of the backing bean is never called.  I can't for the life of me figure out what would be interfering with the call to the backing bean setter.  Everything is the same - the deDecode method, getConvertedValues, etc.

       

      Is there something about the selectItem generation on postback that interferes with calling the setter of the backing bean?  Any insight would be appreciated!

       

      Thanks