7 Replies Latest reply on Jun 9, 2009 1:00 PM by Alireza Salimi

    UIDataAdaptor calls ExtendedDataModel.setRowIndex

    Alireza Salimi Newbie

      Hi,

      I richfaces demo, it has been mentioned that setRowIndex and some other methods
      of DataModel must throw UnsupportedOperationException, but in UIDataAdaptor.java
      line 289, localModel.setRowIndex(index); is called which obviously causes
      exceptions.

      I can't understand whether UIDataAdaptor has bug, or throwing UnsupportedOperationException is wrong, and if it should not be thrown, what should
      be done in setRowIndex of ExtendedDataModel?

      Regards

        • 1. Re: UIDataAdaptor calls ExtendedDataModel.setRowIndex
          Nick Belaevski Master

          Hi,

          Not a bug. This call is nested in UIDataAdaptor#setRowIndex(int) method, so this is the right behavior to call model's setRowIndex() there.
          Are there any particular problems with the exception being thrown?

          • 2. Re: UIDataAdaptor calls ExtendedDataModel.setRowIndex
            Alireza Salimi Newbie

            Hi Nick,

            The exception is THE problem, setRowIndex is called and by throwing this
            exception, no further process is done and error page is shown on the browser.

            BTW, I've implemented setter/getter of rowIndex as the code below, and I
            don't know whether it is a correct implementation or not.

            @Override
            public void setRowIndex(int rowIndex) {
             this.rowIndex = rowIndex;
            }
            
            @Override
            public int getRowIndex() {
             return rowIndex;
            }
            



            • 4. Re: UIDataAdaptor calls ExtendedDataModel.setRowIndex
              Alireza Salimi Newbie

              Hi Nick,

              I created a sample webapp from richfaces-demo's extendedDataModel. All java and
              xhtml files are the same as richfaces-demo. But I still get the
              UnsupportedOperationException, I post my faces-config and web.xml, because
              I guess the only difference between my app and richfaces-demo would be in those
              files. Also the exception stack trace is:

              javax.faces.FacesException: Exception while calling encodeEnd on component : {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /extendedDataModel.xhtml][Class: javax.faces.component.html.HtmlForm,Id: j_id1][Class: org.richfaces.component.html.HtmlDataTable,Id: auction][Class: org.richfaces.component.html.HtmlColumn,Id: j_id10][Class: org.richfaces.component.html.HtmlRichMessage,Id: j_id12]}
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:627)
              at org.richfaces.component.UIRichMessage.encodeEnd(UIRichMessage.java:68)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:281)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:279)
              at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(AbstractRowsRenderer.java:288)
              at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTableRenderer.java:387)
              at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:83)
              at org.richfaces.demo.extendeddatamodel.AuctionDataModel.walk(AuctionDataModel.java:66)
              at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1133)
              at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:104)
              at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:88)
              at org.richfaces.renderkit.AbstractTableRenderer.encodeTBody(AbstractTableRenderer.java:90)
              at org.richfaces.renderkit.AbstractTableRenderer.encodeChildren(AbstractTableRenderer.java:97)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:611)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:250)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
              at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
              at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
              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:178)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
              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:233)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              at java.lang.Thread.run(Thread.java:619)
              Caused by: java.lang.UnsupportedOperationException
              at org.richfaces.demo.extendeddatamodel.AuctionDataModel.getRowIndex(AuctionDataModel.java:108)
              at org.ajax4jsf.component.UIDataAdaptor.getRowIndex(UIDataAdaptor.java:311)
              at javax.faces.component._ComponentUtils.idsAreEqual(_ComponentUtils.java:134)
              at javax.faces.component._ComponentUtils.findComponent(_ComponentUtils.java:97)
              at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:449)
              at org.ajax4jsf.renderkit.RendererUtils.findComponentFor(RendererUtils.java:877)
              at org.richfaces.renderkit.RichMessageBaseRenderer.getMessageIterator(RichMessageBaseRenderer.java:118)
              at org.richfaces.renderkit.html.HtmlRichMessageRenderer.doEncodeEnd(HtmlRichMessageRenderer.java:60)
              at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:624)
              ... 41 more


              faces-config.xml

              <?xml version="1.0" encoding="UTF-8"?>
              <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
               <managed-bean>
               <managed-bean-name>auctionDataModel</managed-bean-name>
               <managed-bean-class>
               org.richfaces.demo.extendeddatamodel.AuctionDataModel</managed-bean-class>
               <managed-bean-scope>session</managed-bean-scope>
               <managed-property>
               <property-name>dataProvider</property-name>
               <property-class>
               org.richfaces.demo.extendeddatamodel.AuctionDataProvider</property-class>
               <value>#{auctionDataProvider}</value>
               </managed-property>
               </managed-bean>
               <managed-bean>
               <managed-bean-name>auctionDataProvider</managed-bean-name>
               <managed-bean-class>
               org.richfaces.demo.extendeddatamodel.AuctionDataProvider</managed-bean-class>
               <managed-bean-scope>session</managed-bean-scope>
               </managed-bean>
               <application>
               <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
               </application>
              </faces-config>
              


              web.xml
              <?xml version="1.0" encoding="UTF-8"?>
              <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
               id="WebApp_ID" version="2.5">
               <display-name>auction</display-name>
               <welcome-file-list>
               <welcome-file>index.html</welcome-file>
               <welcome-file>index.htm</welcome-file>
               <welcome-file>index.jsp</welcome-file>
               <welcome-file>default.html</welcome-file>
               <welcome-file>default.htm</welcome-file>
               <welcome-file>default.jsp</welcome-file>
               </welcome-file-list>
               <context-param>
               <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
               <param-value>.xhtml</param-value>
               </context-param>
               <context-param>
               <param-name>org.richfaces.SKIN</param-name>
               <param-value>blueSky</param-value>
               </context-param>
               <context-param>
               <param-name>org.richfaces.CONTROL_SKINNING</param-name>
               <param-value>enable</param-value>
               </context-param>
               <filter>
               <filter-name>richfaces</filter-name>
               <filter-class>org.ajax4jsf.Filter</filter-class>
               </filter>
               <filter-mapping>
               <filter-name>richfaces</filter-name>
               <servlet-name>Faces Servlet</servlet-name>
               </filter-mapping>
               <servlet>
               <servlet-name>Faces Servlet</servlet-name>
               <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
               <load-on-startup>1</load-on-startup>
               </servlet>
               <servlet-mapping>
               <servlet-name>Faces Servlet</servlet-name>
               <url-pattern>*.faces</url-pattern>
               </servlet-mapping>
              </web-app>
              



              • 5. Re: UIDataAdaptor calls ExtendedDataModel.setRowIndex
                Alireza Salimi Newbie

                Hi Nick,

                I created a sample webapp from richfaces-demo's extendedDataModel. All java and
                xhtml files are the same as richfaces-demo. But I still get the
                UnsupportedOperationException, I post my faces-config and web.xml, because
                I guess the only difference between my app and richfaces-demo would be in those
                files. Also the exception stack trace is:

                javax.faces.FacesException: Exception while calling encodeEnd on component : {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /extendedDataModel.xhtml][Class: javax.faces.component.html.HtmlForm,Id: j_id1][Class: org.richfaces.component.html.HtmlDataTable,Id: auction][Class: org.richfaces.component.html.HtmlColumn,Id: j_id10][Class: org.richfaces.component.html.HtmlRichMessage,Id: j_id12]}
                at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:627)
                at org.richfaces.component.UIRichMessage.encodeEnd(UIRichMessage.java:68)
                at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:281)
                at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
                at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:279)
                at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(AbstractRowsRenderer.java:288)
                at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTableRenderer.java:387)
                at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:83)
                at org.richfaces.demo.extendeddatamodel.AuctionDataModel.walk(AuctionDataModel.java:66)
                at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1133)
                at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:104)
                at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:88)
                at org.richfaces.renderkit.AbstractTableRenderer.encodeTBody(AbstractTableRenderer.java:90)
                at org.richfaces.renderkit.AbstractTableRenderer.encodeChildren(AbstractTableRenderer.java:97)
                at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:611)
                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:250)
                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
                at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
                at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
                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:178)
                at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
                at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
                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:233)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                at java.lang.Thread.run(Thread.java:619)
                Caused by: java.lang.UnsupportedOperationException
                at org.richfaces.demo.extendeddatamodel.AuctionDataModel.getRowIndex(AuctionDataModel.java:108)
                at org.ajax4jsf.component.UIDataAdaptor.getRowIndex(UIDataAdaptor.java:311)
                at javax.faces.component._ComponentUtils.idsAreEqual(_ComponentUtils.java:134)
                at javax.faces.component._ComponentUtils.findComponent(_ComponentUtils.java:97)
                at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:449)
                at org.ajax4jsf.renderkit.RendererUtils.findComponentFor(RendererUtils.java:877)
                at org.richfaces.renderkit.RichMessageBaseRenderer.getMessageIterator(RichMessageBaseRenderer.java:118)
                at org.richfaces.renderkit.html.HtmlRichMessageRenderer.doEncodeEnd(HtmlRichMessageRenderer.java:60)
                at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
                at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:624)
                ... 41 more


                faces-config.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
                 xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
                 <managed-bean>
                 <managed-bean-name>auctionDataModel</managed-bean-name>
                 <managed-bean-class>
                 org.richfaces.demo.extendeddatamodel.AuctionDataModel</managed-bean-class>
                 <managed-bean-scope>session</managed-bean-scope>
                 <managed-property>
                 <property-name>dataProvider</property-name>
                 <property-class>
                 org.richfaces.demo.extendeddatamodel.AuctionDataProvider</property-class>
                 <value>#{auctionDataProvider}</value>
                 </managed-property>
                 </managed-bean>
                 <managed-bean>
                 <managed-bean-name>auctionDataProvider</managed-bean-name>
                 <managed-bean-class>
                 org.richfaces.demo.extendeddatamodel.AuctionDataProvider</managed-bean-class>
                 <managed-bean-scope>session</managed-bean-scope>
                 </managed-bean>
                 <application>
                 <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                 </application>
                </faces-config>
                


                web.xml
                <?xml version="1.0" encoding="UTF-8"?>
                <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                 id="WebApp_ID" version="2.5">
                 <display-name>auction</display-name>
                 <welcome-file-list>
                 <welcome-file>index.html</welcome-file>
                 <welcome-file>index.htm</welcome-file>
                 <welcome-file>index.jsp</welcome-file>
                 <welcome-file>default.html</welcome-file>
                 <welcome-file>default.htm</welcome-file>
                 <welcome-file>default.jsp</welcome-file>
                 </welcome-file-list>
                 <context-param>
                 <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                 <param-value>.xhtml</param-value>
                 </context-param>
                 <context-param>
                 <param-name>org.richfaces.SKIN</param-name>
                 <param-value>blueSky</param-value>
                 </context-param>
                 <context-param>
                 <param-name>org.richfaces.CONTROL_SKINNING</param-name>
                 <param-value>enable</param-value>
                 </context-param>
                 <filter>
                 <filter-name>richfaces</filter-name>
                 <filter-class>org.ajax4jsf.Filter</filter-class>
                 </filter>
                 <filter-mapping>
                 <filter-name>richfaces</filter-name>
                 <servlet-name>Faces Servlet</servlet-name>
                 </filter-mapping>
                 <servlet>
                 <servlet-name>Faces Servlet</servlet-name>
                 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
                 </servlet>
                 <servlet-mapping>
                 <servlet-name>Faces Servlet</servlet-name>
                 <url-pattern>*.faces</url-pattern>
                 </servlet-mapping>
                </web-app>
                



                • 6. Re: UIDataAdaptor calls ExtendedDataModel.setRowIndex
                  Nick Belaevski Master

                  Yes, exactly as I thought, that is MyFaces and it calls get/setRowIndex, so you don't have to throw the exception when these methods are called. Try the following:

                  getRowIndex() { return -1 ;} setRowIndex(idx) {if (idx != -1) throw new IllegalArgumentException()}