0 Replies Latest reply on Oct 17, 2013 9:44 AM by Andrea Agri

    Problems with picklist

    Andrea Agri Newbie

      Hi all,

        i'm using Seam 2.2.2 and richfaces 3.3.1, i have a problem with picklist it's my code

       

       

      import java.util.HashMap;
      import java.util.List;
      
      
      import javax.faces.component.UIComponent;
      import javax.faces.convert.Converter;
      import com.hp.gecpso.entity.asset.ASTCluster;
      import javax.faces.context.FacesContext;
      
      public class ClusterConverter implements Converter {
        //converter uses a HashMap for switching from selectItems to your objects  
          private HashMap <String, ASTCluster> map;  
      
      
        public  ClusterConverter(List<ASTCluster> objekts) {  
                  map=new HashMap<String, ASTCluster>();  
                  for(ASTCluster o : objekts){  
                          map.put(Integer.toString(o.getId()), o);  
                  }  
          }  
      
      
          public ClusterConverter() {
        // TODO Auto-generated constructor stub
        }
      
      
        public Object getAsObject(FacesContext arg0, UIComponent arg1, String string) {  
                  return map.get(string);  
          }  
      
      
          public String getAsString(FacesContext arg0, UIComponent arg1, Object obj) {  
                  if(obj instanceof ASTCluster)   
                          return Integer.toString(((ASTCluster)obj).getId());  
                  return null;  
          }
      
      
      
      
      
      
      }
      

       

      @In(create=true, required=false)
        @Out(required=true,scope=ScopeType.PAGE)
        //private List<SelectItem> leftPickList ;  
        private List<SelectItem> leftPickList ;  
      
        @In(create=true, required=false)
        @Out(required=true,scope=ScopeType.PAGE)
        private List<ASTCluster> pickListResult ;  
      
      .............
      
      public void addRemoveCluster(){
      
      
        @SuppressWarnings("static-access")
        List <ASTCluster> listaCluster= DBManagedServer.getInstance().getClusterSession().getAllcluster();
        pickListResult=assetSelected.getClusters();
      
      
        for (Iterator<ASTCluster> iterator = listaCluster.iterator(); iterator.hasNext();) {
        ASTCluster astCluster = (ASTCluster) iterator.next();
        SelectItem a= new SelectItem(astCluster.getId(), astCluster.getClusterName());
        leftPickList.add(a);
        }
        }
      
      
      
      
      
      

       

      The page

       

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich"
                      xmlns:c="http://java.sun.com/jsp/jstl/core">
      
      
      
      
        <a4j:outputPanel ajaxRendered="true" >
        <a4j:form  id="assetaddcluster" ajaxSubmit="true">  
      
          <rich:simpleTogglePanel label="Asset Search Filter" switchType="ajax" width="100%"> 
            <h:panelGrid columns="8">
            <h:outputLabel value="#{messages['clusters.nome']}" />
                  <h:inputText value="#{clusterFilter.nomeCluster}" />
                 
                  <h:outputLabel value="#{messages['clusters.cluster']}" />
            <h:selectOneMenu  value="#{clusterFilter.tipoCluster}" >
              <s:selectItems value="#{tipoCluster}" var="obj" label="#{obj}" itemValue="#{obj}" noSelectionLabel="Please select..." />  
               </h:selectOneMenu>
            
            </h:panelGrid>
            <div class="actionButtons">
        <a4j:commandButton value="Search" action="#{ASTAssetController.filterCluster()}" reRender="" requestDelay="500"/>
          <a4j:commandButton value="Reset" action="#{ASTAssetController.clearFilterCluster()}" reRender=""/>
                    </div>
            </rich:simpleTogglePanel>
      
      
        <rich:pickList  value="#{pickListResult}" converter="#{converterAsset}">
           <f:selectItems value="#{leftPickList}"/>
              </rich:pickList>
              
        <div class="actionButtons">
        <a4j:commandButton value="Save" action="#{ASTAssetController.saveCluster()}"  oncomplete="Richfaces.hideModalPanel('addClusterOnAsset')" reRender="">
        <a4j:support event="onclick" onsubmit="if (!confirm('#{messages['sitSiteConfirmInsert']}')){return false;}" />
        </a4j:commandButton>
        </div>
      
        </a4j:form>
           <rich:messages id="errorChecksaddcluster" globalOnly="true" styleClass="cntError" style="font-size:12px;width:100%;"/>
          </a4j:outputPanel>
      </ui:composition>
      
      
      
      
      

       

      I can load the value on the left side of the of the picklist but as soon as i use the search button or the save button i get an error

       

      javax.servlet.ServletException: ValueBinding for UISelectMany must be of type List or Array

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)

        at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)

        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

        at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)

        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)

        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

        at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)

        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

        at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)

        at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:295)

       

      I can't find a solution ... someone can help?