3 Replies Latest reply on Jan 14, 2008 7:59 AM by Mike K

    ordering List - Exception when List does not consist of List

    Mike K Newbie

      Hi,

      I get an exception when using ordering List with a List, that does not consist of Strings, but of a Bean with multiple attributes...
      The problem occurs on a page submit only and says basically that
      getDescription() is not a valid method for String (due to the item.description), but I never said it would be a List of Strings !?!?

      I'm using richfaces 3.1.3GA / jsf1.2 RI (1.2_04-b16-p02) / facelets 1.1.13

      Am I doing something wrong here or is that a bug?

      THX Mike

      My page looks like that:

      <rich:orderingList value="#{managedBean.orderingList}" var="item"
       listHeight="300" listWidth="350" >
       <rich:column width="180">
       <f:facet name="header">
       Description
       </f:facet>
       <h:outputText value="#{item.description}"></h:outputText>
       </rich:column>
      <rich:column width="180">
       <f:facet name="header">
       Name
       </f:facet>
       <h:outputText value="#{item.name}"></h:outputText>
       </rich:column>
       </rich:orderingList>
      


      Managed Bean snippet:
       public SimpleTreeBean() {
      
       this.orderingList = new ArrayList<TestPO>();
       this.orderingList.add(new TestPO("Germany", "Deutschland", "de"));
       this.orderingList.add(new TestPO("Switzerland", "Schweiz", "de"));
       this.orderingList.add(new TestPO("Great Britain", "Großbritannien", "de"));
       this.orderingList.add(new TestPO("Sweden", "Schweden", "de"));
       }
       public List<TestPO> getOrderingList() {
       return orderingList;
       }
       public void setOrderingList(List<TestPO> orderingList) {
       this.orderingList = orderingList;
       if (this.orderingList != null) {
       LOGGER.info("first object in list is now: " + this.orderingList.get(0));
       }
       }
      


      Stacktrace after submit:

      javax.faces.FacesException: javax.el.PropertyNotFoundException: /pages/sandbox/treeTest.xhtml @45,48 value="#{item.description}": Property 'description' not found on type java.lang.String
       at javax.faces.component.UIOutput.getValue(UIOutput.java:176)
       at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:286)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.OrderingListRendererBase.encodeOneRow(OrderingListRendererBase.java:183)
       at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:87)
       at org.richfaces.model.OrderingListDataModel.walk(OrderingListDataModel.java:46)
       at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:994)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:107)
       at org.richfaces.renderkit.OrderingListRendererBase.encodeRows(OrderingListRendererBase.java:107)
       at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:139)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.el.PropertyNotFoundException: /pages/sandbox/treeTest.xhtml @45,48 value="#{item.description}": Property 'description' not found on type java.lang.String
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
       at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
       ... 46 more
      


        • 1. Exception when List does not consist of List of Strings => s
          Mike K Newbie

          I resolved the issue by looking in the svn_trunk...
          I think it should be stated somewhere in the documentation, that the orderingList needs a converter!!!
          Couldn't the conversion be solved in a generic manner?

          THX Mike

          /**
           *
           */
          package org.richfaces;
          
          import javax.faces.component.UIComponent;
          import javax.faces.context.FacesContext;
          import javax.faces.convert.Converter;
          
          /**
           * @author mikalaj
           *
           */
          public class OptionItemConverter implements Converter {
          
           /* (non-Javadoc)
           * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
           */
           public Object getAsObject(FacesContext context, UIComponent component,
           String value) {
          
           int index = value.indexOf(':');
          
           return new OptionItem(value.substring(0, index), Integer.valueOf(value.substring(index + 1)).intValue());
           }
          
           /* (non-Javadoc)
           * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
           */
           public String getAsString(FacesContext context, UIComponent component,
           Object value) {
          
           OptionItem optionItem = (OptionItem) value;
           return optionItem.getName() + ":" + optionItem.getPrice();
           }
          
          }
          
          


          • 2. Re: ordering List - Exception when List does not consist of
            Nick Belaevski Master

            Conversion occurs automatically:
            1. If you use arrays as data source (support for generics hasn't been done yet)
            2. JSF knows how to convert the type if

            - it's simple
            or
            - there is PropertyEditor registered for that type

            other cases require explicit converter. See JSF/EL spec. for more info

            • 3. Re: ordering List - Exception when List does not consist of
              Mike K Newbie

              Thanks a lot.

              So I will stick to plain arrays and wait for generics...

              THX Mike