4 Replies Latest reply on Feb 3, 2008 4:44 PM by Kosta Kontos

    rich:listShuttle - is it limited to Collections of Strings?

    Kosta Kontos Newbie


      I have successfully gotten listShuttle working when passing in an ArrayList for both sourceValue and targetValue.

      However what I need is to be able to pass it a List of beans, for example: ArrayList.

      I have tested this and it almost works.

      Let's say that MyBean has two instance variables, int id and String label.

      Now when I set my listShuttle's source and target values to be of type #{backingBean.arrayListOfMyBeansSource} and #{backingBean.arrayListOfMyBeansTarget}, I then can set the listShuttle's var attribute to be "myBean".

      Then in my listShuttle's nested richColumn's outputText value I have "myBean.label"

      This works so far as in it displays the lists correctly (using the labels of all the MyBeans contained in each ArrayList).

      However when I try submit the form the program bombs out with the following error:

      '#{myBean.label}' Property 'label' not found on type java.lang.String

      I am not sure what this means.

      What confuses me is that the lists are both displayed just fine, as in, both of the ArrayList are traversed and each myBean.label is printed in the corresponding list.

      Please advise as to whether I can indeed pass in an ArrayList - I need this functionality. If it is doable, how do I go about a) avoiding that error I pasted above, and b) how do I update the backing bean's value to contain the new ArrayList from the listShuttle's targetValue?

      Thanks very much for your help.

      Ps, my JSF code is below:

      <rich:listShuttle sourceValue="#{contactController.availableGroups}"
       var="group" listsHeight="300" switchByClick="true" controlsType="none"
       sourceCaptionLabel="Available groups"
       targetCaptionLabel="#{contactController.contact.nameFirst}'s current groups">
       <h:outputText value="#{group.name}"></h:outputText>

      As you can see, the MyBean is basically a Group bean, which contains a group name, (the label I was talking about above), group description and group id (for uniquely identifying the group in the database).

      For what it's worth, here is the actual error:

      javax.servlet.ServletException: /contacts/update.jsp(427,5) '#{group.name}' Property 'name' not found on type java.lang.String

      Any help would be greatly appreciated.


        • 1. Re: rich:listShuttle - is it limited to Collections of Strin
          Kosta Kontos Newbie

          Argh it seems this Forum's parser blocks out my ArrayList generic argument.

          The first ArrayList is meant to read

          and the second

          The remaining occurences of ArrayList are easy to understand what I am referring to.

          • 3. Re: rich:listShuttle - is it limited to Collections of Strin
            Kosta Kontos Newbie

            Thanks for your help Sergey.

            I have read through the author's source code that you pointed me to and realised that I needed to implement a custom converter. However I still cannot get it to work. I still get the same error:

            javax.servlet.ServletException: /contacts/update.jsp(429,17) '#{group.name}' Property 'name' not found on type java.lang.String

            I thought I'd give some more info to help solve this issue.

            I have a Group bean, with instance variables int id, String name, String description - along with corresponding getters and setters.

            I also have a Contact bean, and a contact can belong to many groups. Thus I am using the listShuttle component to manage my contacts' group membership in my contact update form.

            Here is the contact's update.jsp code that contains the rich:listShuttle component:

            <rich:listShuttle id="listShuttle"
             sourceCaptionLabel="Available groups"
             targetCaptionLabel="#{contactController.contact.nameFirst}'s current groups"
             listsHeight="300" switchByClick="true" controlsType="none">
             <rich:column><h:outputText value="#{group.name}" /></rich:column>

            Here is the code in my contactController (backing bean) that returns currentGroups and availableGroups (listShuttle attributes):

            public Group[] getAvailableGroups() {
             Group[] availableGroups = new Group[2];
             Group group = new Group(3, "name 3", "description 3");
             availableGroups[0] = group;
             group = new Group(4, "name 4", "description 4");
             availableGroups[1] = group;
             return availableGroups;
            public Group[] getCurrentGroups() {
             Group[] currentGroups = new Group[2];
             Group group = new Group(1, "name 1", "description 1");
             currentGroups[0] = group;
             group = new Group(2, "name 2", "description 2");
             currentGroups[1] = group;
             return currentGroups;
            public void setAvailableGroups(Group[] availableGroups) {
             System.out.println("in setAvailableGroups()");
            public void setCurrentGroups(Group[] currentGroups) {

            As you can see, I just have simple System.out.println statements in the setters to test that the program gets to this stage, which it never does. All I see in my console output is that error I pasted above and that's all.

            Also, I implemented the custom converter following the example code you linked me to, and I even put simple System.out.println methods in both getAsString and getAsObject methods - but again, the program doesn't even make it that far.

            So basically, from my humble understanding of the JSF Lifecycle, the program is failing somewhere in the Apply Request Values phase - but before it gets into my custom converter's getAsObject method.

            For what it's worth, the JSF page initially loads just fine, with all 4 groups and their variables showing up in the listShuttle correctly. It then fails when I click "update" to submit the form.

            Please help, thanks.


            • 4. Re: rich:listShuttle - is it limited to Collections of Strin
              Kosta Kontos Newbie

              Please note that the problem has been fixed - it was a silly typo in my managed-bean configuration.

              Nick Belaevski, you are my hero.