1 Reply Latest reply on Jun 1, 2008 10:58 AM by Khaled Al-Shehri

    rich:listShuttle-Property not found on type java.lang.String

    Khaled Al-Shehri Newbie


      I'm useing <rich:listShuttle> tag and i pass to it 2 lists : ArrayList
      the lists are displayed correctly but when the select items and submit the form, the below exception is raised.

      Service (value object):

      public class Service implements Serializable
      // 3 properties + getters + setters


      GetPackage (backing bean)
      public class GetPackageInfo extends SuperBean {
       private ServicePackage pack = new ServicePackage();
       private List<Service> services;
       private List<Service> selectedList = new ArrayList<Service>();
       private List<Service> availableList = new ArrayList<Service>();
      
       private boolean saved = false;
      
       public GetPackageInfo() throws Exception{
       super();
       initOptions();
       }
      
       public String update(){
       // update package info
       }
      
       private void initOptions(){
       // lookup the lists
       }
      
      }



      JSP
      <rich:listShuttle orderControlsVisible="false" var="service" fastOrderControlsVisible="false" sourceValue="#{getPackageInfo.availableList}" targetValue="#{getPackageInfo.selectedList}">
      
      <h:column>
      <h:outputText value="#{service.englishName}" />
      </h:column>
      </rich:listShuttle>
      



      Exception (raised only on submit)
      org.apache.jasper.el.JspPropertyNotFoundException: /jsp/getPackage.jsp(61,6) '#{service.englishName}' Property 'englishName' not found on type java.lang.String
       org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:104)
       javax.faces.component.UIOutput.getValue(UIOutput.java:173)
       com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
       com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
       com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
       javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
       org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:286)
       org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       org.richfaces.renderkit.ListShuttleRendererBase.encodeOneRow(ListShuttleRendererBase.java:182)
       org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:86)
       org.richfaces.model.ListShuttleDataModel.walk(ListShuttleDataModel.java:57)
       org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1127)
       org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:106)
       org.richfaces.renderkit.ListShuttleRendererBase.encodeRows(ListShuttleRendererBase.java:99)
       org.richfaces.renderkit.html.ListShuttleRenderer.doEncodeChildren(ListShuttleRenderer.java:269)
       org.richfaces.renderkit.html.ListShuttleRenderer.doEncodeChildren(ListShuttleRenderer.java:255)
       org.richfaces.renderkit.ListShuttleRendererBase.encodeChildren(ListShuttleRendererBase.java:226)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
       javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
       com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:245)
       com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:176)
       org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       org.displaytag.filter.CarportalResponseOverrideFilter.doFilter(CarportalResponseOverrideFilter.java:58)
       org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
       com.elm.carportal.web.filters.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:48)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      


        • 1. Re: rich:listShuttle-Property not found on type java.lang.St
          Khaled Al-Shehri Newbie

          FIXED

          by following steps:

          1- adding a converter

          import javax.faces.component.UIComponent;
          import javax.faces.context.FacesContext;
          
          import com.elm.carportal.beans.Service;
          import com.elm.carportal.web.util.WebConstants;
          import com.elm.carportal.web.util.WebUtil;
          
          public class ServiceConverter implements javax.faces.convert.Converter{
          
           public Object getAsObject(FacesContext context, UIComponent component,
           String value) {
          
           int index = value.indexOf(':');
           Service service = new Service();
           service.setId(Integer.valueOf(value.substring(0, index)));
           service.setEnglishName(value.substring(index + 1));
          
           return service;
           }
          
           public String getAsString(FacesContext context, UIComponent component,
           Object value) {
          // get object as string
           }
          
          }



          2- register the converter in faces-config.xml:
          <converter>
           <converter-id>serviceConverter</converter-id>
           <converter-class>com.elm.carportal.web.converters.ServiceConverter</converter-class>
           </converter>


          3- add the converter attribute to
          <rich:listShuttle orderControlsVisible="false" var="service" fastOrderControlsVisible="false" sourceValue="#{getPackageInfo.availableList}" targetValue="#{getPackageInfo.selectedList}" converter="serviceConverter">
          
          <h:column>
          <h:outputText value="#{service.englishName}" />
          </h:column>
          </rich:listShuttle>


          4- finally in Service override the value object equals() method:
          public boolean equals(Object obj) {
           if (this == obj){
           return true;
           }
           if (obj == null){
           return false;
           }
           if (getClass() != obj.getClass()){
           return false;
           }
          
           final Service other = (Service) obj;
           if (id == 0) {
           if (other.id != 0){
           return false;
           }
           } else if (!(id == other.id)){
           return false;
           }
           return true;
           }