2 Replies Latest reply on Jun 8, 2010 9:33 AM by hbender

    pickList error: value of UIPickList component is not of type Array or List

    hbender

      Here my xhtml code:

       

      <rich:panel>
              <h:form>
                  <rich:pickList value="#{dmPermissionListOfRole}">

                        <f:selectItems value="#{dmPermissionListOfRoleInverse}"/>

                  </rich:pickList>   
          </h:form>
      </rich:panel>

       

      and here the code of the backing bean (seam component):

       

          @DataModel(value="dmPermissionListOfRole")
          private List<Permission> permissionListOfRole;
         
          @Factory("dmPermissionListOfRole")
          public void initPermissionList() {...}
         
          @DataModel(value="dmPermissionListOfRoleInverse")
          private List<Permission> permissionListOfRoleInverse;
         
          @Factory("dmPermissionListOfRoleInverse")
          public void initPermissionListInverse() {...}

       

      Running this code throws exception:

       

      java.lang.IllegalArgumentException: Error: value of UIPickList component is not of type Array or List
          at org.richfaces.renderkit.PickListRenderer.getValuesList(PickListRenderer.java:146)

          ....

       

      The same xhtml has a rich:dataTable with the same value ("dmPermissionListOfRole") which is rendered without problems.

       

      If I omit the value of the pickList, the error is:

       

      java.lang.IllegalArgumentException: Value  of tag <selectItems> attribute is incorrect.
          at org.ajax4jsf.util.SelectUtils.getSelectItems(SelectUtils.java:100)
          at org.richfaces.renderkit.PickListRenderer.encodeRows(PickListRenderer.java:243)
          at org.richfaces.renderkit.PickListRenderer.encodeSourceRows(PickListRenderer.java:359)

          ....

       

      What is wrong? (Using RichFaces bundled with JBoss DevStudio 3.0, therefore I do not know which version of RichFaces is used. Where can I find which version is bundled with JBoss DevStudio?)

       

      Heri

        • 1. Re: pickList error: value of UIPickList component is not of type Array or List
          ilya_shaikovsky

          1) selectItems tag should be pointed to list of selectItem objects. Or you should provide the converter for your Permission object.

          2) the same for value attribute.

           

          check please http://community.jboss.org/message/521331#521331 and related issue also for more info.

          • 2. Re: pickList error: value of UIPickList component is not of type Array or List
            hbender

            tks Ilya for clarification.

             

            Meanwhile I found - by stepping through the code and try'n'error - nearly the same result.

             

            The selectItems must indeed be provided by a List<SelectItem>. But if the value is also populated by such a list, the PickListRenderer.selectItemsForSelectedList() would not evalutate to equal:

             

              if (lookupItem.equals(selectItem.getValue())) {
                                    selectItemForSelectedValues.add(selectItem);
                                }

            (the lookupItem is taken from the values list, here an SelectItem, and compared against the selectItem.getValue(), which is my embedded class -> never equals).

            Therefore the values have to be populated by the payload class, and a Converter has to be provided.

             

            It would be nice if this method would behave correctly if the value list also contains SelecItem instances. Something like:

             

            Object lookup =  ( lookupItem instanceof SelectItem ? lookupItem.getValue() : lookupItem );

            if (lookup.equals(selectItem.getValue())) {
                                     selectItemForSelectedValues.add(selectItem);
                                 }

             

            BTW: My original collections are of type set. Therefore I have to transform them to a list. Is there a inherent reason why the pickList does not support all types of Collection as value parameter?

             

            And if there is a good reason: The reference (http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_pickList.html) and the java doc (http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/index.html) should state this fact clearly.

             

            Heri