4 Replies Latest reply on Feb 2, 2012 5:03 PM by Recep YALMAN

    Richfaces 4.0.0.Final : <rich:select> : objects as value

    Thomas Bétrancourt Newbie

      Hi,

       

      I would like to fill a <rich:select> with objects as item. With previous version of richfaces, there were converters to do this.

       

      I've defined my select like this :

      <rich:select id="repositories" value="#{browserNavigation.currentRepository}">
          <f:selectItems value="#{browserNavigation.repositories}" var="repository" itemValue="#{repository}" itemLabel="#{repository.path}" />                
      </rich:select>
      

       

      This my browserNavigation code :

      @ManagedBean(name = "browserNavigation", eager = true)
      @SessionScoped
      public class NavigationController {
          private RepositoryDao repositoryDao;
          private Repository currentRepository;
          private Set<Repository> repositories;
      
          public NavigationController() {
              this.repositoryDao = new RepositoryMockDao();
              this.repositories = this.repositoryDao.fetchAll();
          }
      
          public Repository[] getRepositories() {
              return this.repositories.toArray(new Repository[this.repositories.size()]);
          }
      
          public void setCurrentRepository(Repository currentRepository) {
              this.currentRepository = currentRepository;
          }
      
          public Repository getCurrentRepository() {
              return this.currentRepository;
          }
      }
      

       

      I've the good rendering : the repositories's paths are displayed as label in the select.

       

      When i select an option in the component, i obtain this following exception :

      javax.faces.component.UpdateModelException: javax.el.ELException: /browser.xhtml @215,105 value="#{browserNavigation.currentRepository}": Cannot convert net.rclsilver.ftm.domain.Repository@6af790 of type class java.lang.String to class net.rclsilver.ftm.domain.Repository
          at javax.faces.component.UIInput.updateModel(UIInput.java:842)
          at javax.faces.component.UIInput.processUpdates(UIInput.java:725)
          at javax.faces.component.UIForm.processUpdates(UIForm.java:265)
          at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:59)
          at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1442)
          at javax.faces.component.UIForm.visitTree(UIForm.java:328)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1453)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1453)
          at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:249)
          at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:229)
          at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:208)
          at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1237)
          at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:103)
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.lang.Thread.run(Unknown Source)
      Caused by: javax.el.ELException: /browser.xhtml @215,105 value="#{browserNavigation.currentRepository}": Cannot convert net.rclsilver.ftm.domain.Repository@6af790 of type class java.lang.String to class net.rclsilver.ftm.domain.Repository
          at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:132)
          at javax.faces.component.UIInput.updateModel(UIInput.java:808)
          ... 32 more
      

       

      My Repository class implements the Serializable interface.

       

      My goal is to store the current repository in the browserNavigation bean and the refresh a treeview. When the treeview will be showed or refreshed, a dataview will show up the files and directories where are inside this repository.

       

      Thanks in advance for your support.