0 Replies Latest reply on Feb 11, 2011 11:54 AM by elliot2k

    rich:scrollableDataTable bug - Seam or richfaces?

    elliot2k

      Ive come across a bug, I think its Richfaces but thought I would check on here first.


      Here's my code:



           
      <script>
      //<![CDATA[
           function hasKeyData() {
                var dataExists = false;
                jQuery('#entryKeyData input').each(function(){
                     if(this.type == 'text' && this.id != 'mainform:brand') {
                          if(this.value.length > 0) {dataExists = true;}
                     } else if(this.type == 'checkbox') {
                          if(this.checked) {dataExists = true;}
                     }
                });
                
                jQuery('#entryKeyData option:selected').each(function(){
                     if(this.text != 'Select an item') {
                          dataExists = true;
                     }
                });
                return dataExists;
           }
      
           function categorySelection() {
                if(hasKeyData()) { 
                     var answer = confirm('This will reset any key data for this record. Are you sure?');
                     if (!answer) {
                          return false;
                     } 
                }
                return true;
           }
      
           //]]>
      </script>
      
           
           Search to change the category<br />
           <h:form id="catSearch">
                <h:inputText id="categoryName" value="#{categorySearch.search}" />
      
                <a4j:commandButton value="Search" event="onclick"
                     reRender="categorySearchPanel" ignoreDupResponses="true"
                     oncomplete="setCaretToEnd(event);"
                     action="#{categorySearch.searchAction}" id="searchButton">
                     <s:defaultAction />
                </a4j:commandButton>
      
      
                <p>&#160;</p>
                <a4j:outputPanel id="categorySearchPanel">
                     <rich:scrollableDataTable id="categoryListResults" var="_cmsCategory"
                          value="#{categoryResults}" rendered="#{categoryResults.size gt 0}"
                          width="400px" height="150px">
      
                          <rich:column width="375px"
                               id="categoryName" headerClass="scrollableDataTableHeader"
                               colspan="2">
                               <f:facet name="header">Category name</f:facet>
                               <s:link value="#{_cmsCategory.categoryName}"
                                    action="#{cmsListingsHome.setCategory}"
                                    onclick="if(!categorySelection()) return false;">
                                    <f:param name="cmsCategoryIdCat" value="#{_cmsCategory.idCat}" />
                               </s:link>
                          </rich:column>
      
                     </rich:scrollableDataTable>
                </a4j:outputPanel>
           </h:form>



      The above code will display a simple textbox to enter a search string.
      Upon submitting this a search is performed and the scrollabledatatable is displayed with the result in it. It is then possible to click on one of the result to select it an perform an action, in this case the rest of the page is displayed dynamically depending on the category selected(not shown). Also, if another category is chosen after the user has started entering data in the rest of the screen a confim box is displayed asking the user to confirm their action as their changes will be lost.


      The problem is this:
      If when this confirm dialog box is displayed the user selects no, the code returns false so that the onclick() does nothing. If the user then changes the search text and clicks search the error below is thrown...





      2011-02-11 16:26:07,058 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-localhost%2F127.0.0.1-8080-6) / by zero
      java.lang.ArithmeticException: / by zero
           at org.richfaces.renderkit.html.SelectionRendererContributor.decode(SelectionRendererContributor.java:159)
           at org.richfaces.renderkit.CompositeRenderer$1.execute(CompositeRenderer.java:77)
           at org.richfaces.renderkit.CompositeRenderer$Command.execute(CompositeRenderer.java:61)
           at org.richfaces.renderkit.CompositeRenderer.doDecode(CompositeRenderer.java:149)
           at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)
           at org.richfaces.renderkit.html.ScrollableDataTableBaseRenderer.doDecode(ScrollableDataTableBaseRenderer.java:679)
           at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)
           at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)
           at org.ajax4jsf.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:1141)
           at org.ajax4jsf.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:1150)
           at org.richfaces.component.UIScrollableDataTable.processDecodes(UIScrollableDataTable.java:169)
           at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
           at javax.faces.component.UIForm.processDecodes(UIForm.java:208)
           at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:392)
           at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
           at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:409)
           at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           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)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:373)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:500)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           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:235)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
           at java.lang.Thread.run(Unknown Source)
      2011-02-11 16:26:07,059 SEVERE [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-localhost%2F127.0.0.1-8080-6) JSF1054: (Phase ID: APPLY_REQUEST_VALUES 2, View ID: /CMS_ProductEdit.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1c8fc50]



      I have also tested this by replacing the onclick with:

      onclick="return false;"

      and this produces the same effect. No where in the stack trace or in the log is my code called. When selecting to search again it doesnt seem to call my code either. It certainly looks like the divide by zero if happening in the scrollabledatatable.


      Am I right? Can anyone else reproduce this?
      Should this be on the Richfaces site?