4 Replies Latest reply on Jul 9, 2008 10:31 AM by Florian Marwede

    crash by delete the last item in scrollableDataTable

    Dongyao Zhao Novice

      i have implemented a scrollableDataTable for message, there is a checkbox in every line, with that you can acknowledge the message. If the checkbox is selected, delete the message object from Message-List. When i delete the last message, i got the error message and crash.

      17.06.2008 10:44:35 com.sun.facelets.FaceletViewHandler handleRenderException
      SCHWERWIEGEND: Error Rendering View[/restricted/paneDefinition.xhtml]
      javax.faces.FacesException: java.lang.IndexOutOfBoundsException: Index: 0,Size: 0
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:675)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
       at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:509)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       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:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:256)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:362)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.IndexOutOfBoundsException: Index: 0,Size: 0
       at java.util.SubList.rangeCheck(AbstractList.java:849)
       at java.util.SubList.get(AbstractList.java:722)
       at org.richfaces.model.ScrollableTableDataModel.getObjectById(ScrollableTableDataModel.java:165)
       at org.richfaces.model.DataModelCache.getObjectById(DataModelCache.java:103)
       at org.richfaces.model.ScrollableTableDataModel.loadAndMap(ScrollableTableDataModel.java:232)
       at org.richfaces.model.ScrollableTableDataModel.getRowData(ScrollableTableDataModel.java:190)
       at org.richfaces.model.DataModelCache.getRowData(DataModelCache.java:126)
       at org.richfaces.model.ScrollableTableDataModel.isRowAvailable(ScrollableTableDataModel.java:206)
       at org.richfaces.model.DataModelCache.isRowAvailable(DataModelCache.java:148)
       at org.ajax4jsf.component.UIDataAdaptor.isRowAvailable(UIDataAdaptor.java:268)
       at org.ajax4jsf.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:358)
       at org.ajax4jsf.component.UIDataAdaptor$ComponentVisitor.process(UIDataAdaptor.java:96)
       at org.ajax4jsf.component.UIDataAdaptor.encodeAjaxChild(UIDataAdaptor.java:494)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:105)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:68)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:116)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:267)
       at org.ajax4jsf.component.AjaxViewRoot$4.invokeContextCallback(AjaxViewRoot.java:484)
       at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:672)
      

      message.xhtml

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
       <a4j:jsFunction name="acknowlegeAllAlarm" action="#{mainBean.acknowledgeAllAlarms}" />
       <rich:contextMenu id="menu" event="oncontextmenu" submitMode="none">
       <rich:menuItem value="Acknowledge all alarms" onclick="acknowlegeAllAlarm();"/>
       </rich:contextMenu>
       <rich:scrollableDataTable id="alarmPaneId"
       height="#{layoutBean.alarmTblHeight}"
       width="#{layoutBean.alarmTblWidth}"
       value="#{appData.alarms}" var="alarm"
       rowClasses="taskRows" columnClasses="taskColumns">
      
       <rich:column sortable="false">
       <f:facet name="header">
       <h:outputText value="Start Time"/>
       </f:facet>
       <h:outputText value="#{alarm.startTimeString}" />
       </rich:column>
       <rich:column sortable="false">
       <f:facet name="header">
       <h:outputText value="End Time"/>
       </f:facet>
       <h:outputText value="#{alarm.endTimeString}"
       title="#{alarm.endTimeString}"/>
       </rich:column>
       <rich:column sortable="false">
       <f:facet name="header">
       <h:outputText value="Text"/>
       </f:facet>
       <h:outputText value="#{alarm.text}" title="#{alarm.text}"/>
       </rich:column>
       <rich:column sortable="false" width="80">
       <f:facet name="header">
       <h:outputText value="Category"/>
       </f:facet>
       <h:outputText value="#{alarm.category}" title="#{alarm.category}"/>
       </rich:column>
       <rich:column sortable="false" width="60">
       <f:facet name="header">
       <h:outputText value="Severity"/>
       </f:facet>
       <h:outputText value="#{alarm.severity}" />
       </rich:column>
       <rich:column sortable="false" width="78">
       <f:facet name="header">
       <h:outputText value="Port"/>
       </f:facet>
       <h:outputText value="#{alarm.portName}"
       title="#{alarm.portName}"/>
       </rich:column>
       <rich:column sortable="false">
       <f:facet name="header">
       <h:outputText value="Acknowledged"/>
       </f:facet>
       <h:selectBooleanCheckbox value="#{alarm.acknowledged}"
       onclick="this.disabled=true;sendAck#{alarm.id}()">
       <a4j:jsFunction reRender="actualAlarmId" name="sendAck#{alarm.id}"
       action="#{mainBean.alarmAcknowledged}" ajaxSingle="true">
       <a4j:actionparam name="id" value="#{alarm.id}" />
       </a4j:jsFunction>
       </h:selectBooleanCheckbox>
       </rich:column>
       <rich:componentControl for="menu" operation="show"/>
      
       </rich:scrollableDataTable>
      <script>
       jQuery('.iBox')[0].childNodes[1].firstChild.childNodes[1].firstChild.height="";
      </script>
      
      </ui:composition>
      


      reRender is controlled by java bean and a4j:push
      case UPDATED_ALARM:
       case DELETED_ALARM:
       {
       componentsToUpdate = "alarmPaneId";
       break;
       }
      


      a4j:push
      
      <a4j:form>
       <a4j:region>
       <a4j:push reRender="#{mainBean.componentsToUpdate}"
       eventProducer="#{mainBean.addCommandEventListener}" interval="3000" />
       </a4j:region>
       </a4j:form>