7 Replies Latest reply on May 23, 2009 10:56 AM by Shivaji Byrapaneni

    rich:ListShuttle issue

    Shivaji Byrapaneni Newbie

      Hi i tried a simple example of rich:listShuttle provided by richfaces

      here is my jsp

      <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <!-- RichFaces tag library declaration -->
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
      <html>
      <head>
      <title>RichFaces selector demo</title>
      <style>
      .pic {
       margin-bottom: -4px;
       margin-right: 2px;
      }
      </style>
      </head>
      <body>
      <f:view>
       <a4j:form id="approverForm">
       <rich:toolBar id="toolBar" itemSeparator="line" height="28px">
       <c:forEach items="#{toolBar.items}" var="item">
       <h:panelGroup>
       <h:graphicImage value="#{item.iconURI}" styleClass="pic" />
       <h:outputLink value="#"
       style="color:#{a4jSkin.generalTextColor}; text-decoration:none;">
       <h:outputText value="#{item.label}" />
       </h:outputLink>
       </h:panelGroup>
       </c:forEach>
       </rich:toolBar>
       <rich:spacer height="20" />
      
       <rich:messages />
      
       <rich:listShuttle sourceValue="#{toolBar.freeItems}"
       targetValue="#{toolBar.items}" var="items"
       sourceCaptionLabel="Available Items"
       targetCaptionLabel="Currently Active Items" id="listShuttle"
       converter="myConverter">
       <rich:column width="18">
       <h:graphicImage value="#{items.iconURI}"></h:graphicImage>
       </rich:column>
       <rich:column>
       <h:outputText value="#{items.label}"></h:outputText>
       </rich:column>
       <a4j:support event="onlistchanged" reRender="toolBar" />
       <a4j:support event="onorderchanged" reRender="toolBar" />
       </rich:listShuttle>
      </f:view>
       </a4j:form >
      </body>
      </html>
      


      and my managed bean is this

      package demo;
      
      import java.util.ArrayList;
      
      public class Approver {
       private ArrayList<ItemVO> items = new ArrayList<ItemVO>();
       private ArrayList<ItemVO> freeItems = new ArrayList<ItemVO>();
      
       public Approver() {
       items.add(new ItemVO("./Images/create_doc.gif", "Create Doc"));
       items.add(new ItemVO("./Images/create_folder.gif", "Create Folder"));
       items.add(new ItemVO("./Images/delete.gif", "Delete"));
       items.add(new ItemVO("./Images/find.gif", "Find"));
       items.add(new ItemVO("./Images/open.gif", "Open"));
       items.add(new ItemVO("./Images/save_all.gif", "Save All"));
       items.add(new ItemVO("./Images/save.gif", "Save"));
       }
      
       public ArrayList<ItemVO> getItems() {
       return items;
       }
      
       public void setItems(ArrayList<ItemVO> items) {
       this.items = items;
       }
      
       public ArrayList<ItemVO> getFreeItems() {
       return freeItems;
       }
      
       public void setFreeItems(ArrayList<ItemVO> freeItems) {
       this.freeItems = freeItems;
       }
      
      }
      
      
      
      and itemVO contains just a string with the names and getters, setters to that names used in jsp.
      
      with all the above page is getting rendered as expected but when i tried to do any operations im getting this error
      
      
      "Component j_id_jsp_1561931891_1:listShuttle has invalid value expression demo.ItemVO@139deb9"
      
      
      
      and was unable to move from that screen
      
      please help
      Thanks in advance
      


        • 1. Re: rich:ListShuttle issue
          Shivaji Byrapaneni Newbie

          and the rich:toolbar is not not rendering anything other than a cross mark...

          i cant understand why it is so

          the same list in teh rich:list shuttle is rendering correctly along with the images and text that i provided.

          Please help me im strucked up out of this...

          • 2. Re: rich:ListShuttle issue
            Shivaji Byrapaneni Newbie

            could any body help me please

            • 3. Re: rich:ListShuttle issue
              Nick Belaevski Master

               

              "shivaji.byrapaneni" wrote:
              and the rich:toolbar is not not rendering anything other than a cross mark...

              i cant understand why it is so

              the same list in teh rich:list shuttle is rendering correctly along with the images and text that i provided.

              Please help me im strucked up out of this...

              That's because of incorrect URI for "c" tags, for JSP it should be:
              <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


              • 4. Re: rich:ListShuttle issue
                Nick Belaevski Master

                How does "myConverter" look like? Does ItemVO have correct equals/hashCode methods implementation?

                • 5. Re: rich:ListShuttle issue
                  Shivaji Byrapaneni Newbie

                  Thanks a lot for reply

                  i had changed the @ tablib you had provided but that didnt help and made my screen to crash.

                  doing some changes in JSP made to see the screen but the same problem.

                  here is my JSP

                  <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
                  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                  <!-- RichFaces tag library declaration -->
                  <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
                  <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
                  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
                  <html>
                  <head>
                  <title>RichFaces selector demo</title>
                  <style>
                  .pic {
                   margin-bottom: -4px;
                   margin-right: 2px;
                  }
                  </style>
                  </head>
                  <body>
                   <rich:toolBar id="toolBar" itemSeparator="line" height="28px">
                   <c:forEach items="${toolBar.items}" var="item">
                   <h:panelGroup>
                   <h:graphicImage value="#{item.iconURI}" styleClass="pic" />
                   <h:outputLink value="#"
                   style="color:#{a4jSkin.generalTextColor}; text-decoration:none;">
                   <h:outputText value="#{item.label}" />
                   </h:outputLink>
                   </h:panelGroup>
                   </c:forEach>
                   </rich:toolBar>
                   <rich:spacer height="20" />
                  
                   <rich:messages />
                  
                   <rich:listShuttle sourceValue="#{toolBar.freeItems}"
                   targetValue="#{toolBar.items}" var="items"
                   sourceCaptionLabel="Available Items"
                   targetCaptionLabel="Currently Active Items" id="listShuttle"
                   converter="myConverter">
                   <rich:column width="18">
                   <h:graphicImage value="#{items.iconURI}"></h:graphicImage>
                   </rich:column>
                   <rich:column>
                   <h:outputText value="#{items.label}"></h:outputText>
                   </rich:column>
                   <a4j:support event="onlistchanged" reRender="toolBar" />
                   <a4j:support event="onorderchanged" reRender="toolBar" />
                   </rich:listShuttle>
                  </body>
                  </html>
                  


                  my ItemVO contains this

                  package demo;
                  
                  public class ItemVO {
                  
                   private String iconURI;
                   private String label;
                  
                   public ItemVO(String iconURI, String label) {
                   this.iconURI = iconURI;
                   this.label = label;
                   }
                  
                   public String getIconURI() {
                   return iconURI;
                   }
                  
                   public void setIconURI(String iconURI) {
                   this.iconURI = iconURI;
                   }
                  
                   public String getLabel() {
                   return label;
                   }
                  
                   public void setLabel(String label) {
                   this.label = label;
                   }
                  
                   @Override
                   public boolean equals(Object obj) {
                   if (this == obj)
                   return true;
                   if ((obj == null) || (obj.getClass() != this.getClass()))
                   return false;
                   ItemVO itemVO = (ItemVO) obj;
                   if (itemVO.iconURI.equals(this.iconURI)
                   && itemVO.label.equals(this.label))
                   return true;
                  
                   return false;
                   }
                  
                   @Override
                   public int hashCode() {
                   int hash = 7;
                   hash = 31 * hash;
                   hash = 31 * hash + (null == this.label ? 0 : this.label.hashCode());
                   return hash;
                  
                   }
                  
                  }
                  
                  


                  and myConverter contains this

                  package demo;
                  
                  import javax.faces.component.UIComponent;
                  import javax.faces.context.FacesContext;
                  import javax.faces.convert.Converter;
                  
                  public class MyConverter implements Converter {
                  
                   @Override
                   public Object getAsObject(FacesContext context, UIComponent component,
                   String value) {
                   System.out.println("getAsObject executed...");
                   System.out.println("Value has this "+value);
                   return value;
                   }
                  
                   @Override
                   public String getAsString(FacesContext context, UIComponent component,
                   Object value) {
                   System.out.println("getAsString executed...");
                   System.out.println("Value has this "+value.toString());
                   return value.toString();
                   }
                  
                  }
                  
                  


                  please help. will be waiting for response.

                  Thanks in advance.

                  • 6. Re: rich:ListShuttle issue
                    Shivaji Byrapaneni Newbie

                    doing thsi in my converter had solved my problem now it works fine

                    package demo;
                    
                    import javax.faces.component.UIComponent;
                    import javax.faces.context.FacesContext;
                    import javax.faces.convert.Converter;
                    
                    public class MyConverter implements Converter {
                    
                     @Override
                     public Object getAsObject(FacesContext context, UIComponent component,
                     String value) {
                     System.out.println("getAsObject executed...");
                     System.out.println("Value has this " + value);
                     int index = value.indexOf(':');
                     return new ItemVO(value.substring(0, index), value.substring(index + 1));
                     }
                    
                     @Override
                     public String getAsString(FacesContext context, UIComponent component,
                     Object value) {
                     System.out.println("getAsString executed...");
                     System.out.println("Value has this " + value.toString());
                     ItemVO itemVO = (ItemVO) value;
                     return itemVO.getIconURI() + ":" + itemVO.getLabel();
                     }
                    
                    }
                    
                    


                    but still i cant see any images or text in the rich:toolBar.
                    pls help

                    • 7. Re: rich:ListShuttle issue
                      Shivaji Byrapaneni Newbie

                      with this jsp its not crashing and not producing images or concerned text in rich:toolbar

                       <rich:toolBar id="toolBar" itemSeparator="line" height="28px">
                       <c:forEach items="${toolBar.items}" var="item"> <h:panelGroup>
                       <h:graphicImage value="#{item.iconURI}" styleClass="pic" />
                       <h:outputLink value="#"
                       style="color:#{a4jSkin.generalTextColor}; text-decoration:none;">
                       <h:outputText value="#{item.label}" />
                       </h:outputLink>
                       </h:panelGroup>
                       </c:forEach>
                       </rich:toolBar>
                      
                      


                      if i use this

                      <rich:toolBar id="toolBar" itemSeparator="line" height="28px">
                       <c:forEach items="#{toolBar.items}" var="item"> <h:panelGroup>
                       <h:graphicImage value="#{item.iconURI}" styleClass="pic" />
                       <h:outputLink value="#"
                       style="color:#{a4jSkin.generalTextColor}; text-decoration:none;">
                       <h:outputText value="#{item.label}" />
                       </h:outputLink>
                       </h:panelGroup>
                       </c:forEach>
                       </rich:toolBar>
                      
                      
                      



                      its giving compliation error

                      javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in &lt;forEach&gt;
                      
                      


                      pls help