Got an exception when upgrading to 2.2

UI Components for JSF
csfreebird
Posts: 13
Joined: 13 Nov 2010, 15:35

08 Feb 2011, 17:10

My environment:
UBuntu 10.10,Maven3.02,Spring3.0.5,MyBatis3.0.4,MySQL GlassFishV3
Browser:FireFox 3 or Chrome 9

[#|2011-02-08T22:52:44.761+0800|SEVERE|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=27;_ThreadName=Thread-1;|javax.faces.FacesException: Unexpected error restoring state for component with id j_idt3. Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:273)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1485)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
at com.sun.faces.component.visit.VisitUtils.doFullNonIteratingVisit(VisitUtils.java:75)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:257)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:181)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:448)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1432)
at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:265)
... 39 more
|#]

I am confused because I can't find j_idt3 id in the finalize hmtl file in browser.My page is a little bit complex,when clicking the left command link,the center page will change.
Here is my template file:mainTemplate.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--
<h:outputStylesheet name="themes/hot-sneaks/skin.css"/>
-->
<title><ui:insert name="windowTitle"/></title>
</h:head>

<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="top" height="120" header="KaiMeiTech" resizable="true" closable="true" collapsible="true">
<center>
<p:graphicImage id="title" value="resources/images/title.gif"/>
</center>
</p:layoutUnit>
<p:layoutUnit position="bottom" height="75" header="Bottom" resizable="true" closable="true" collapsible="true">
<ui:insert name="bottom"/>
</p:layoutUnit>
<p:layoutUnit position="left" width="200" header="Functions" resizable="true" closable="true" collapsible="true">
<ui:insert name="left"/>
</p:layoutUnit>
<p:layoutUnit position="center">
<ui:insert name="content"/>
</p:layoutUnit>
<p:layoutUnit position="right" width="200" header="Displays" resizable="true" closable="true" collapsible="true">
<ui:insert name="right"/>
</p:layoutUnit>
</p:layout>
</h:body>
</html>

home.xhtml uses the above template file.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/template/mainTemplate.xhtml">
<ui:define name="windowTitle">
Home Title
</ui:define>
<ui:define name="left">
<ui:include src="#{userHome.leftFile}"/>
</ui:define>
<ui:define name="content">
<p:outputPanel id="part">
<ui:include src="#{userHome.partFile}"/>
</p:outputPanel>
</ui:define>
<ui:define name="right">
<ui:include src="/part/display.xhtml"/>
</ui:define>
<ui:define name="bottom">
<h:form id="bottomForm">
<p:poll interval="3" update="msg"/>
<p:ajaxStatus style="width:16px;height:16px;">
<f:facet name="start">
<h:graphicImage value="/images/ajaxloading.gif" />
</f:facet>
</p:ajaxStatus>
</h:form>
</ui:define>
</ui:composition>
</html>

This is my left side file:userLeft.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:form id="leftForm">
<h:panelGrid id="lgrid" border="0" columns="1">
<p:commandLink id="c1" style="margin-right:20px;" actionListener="#{userHome.click1}" update="part">
<h:outputText value="Welcome" />
</p:commandLink>
<p:commandLink id="c2" style="margin-right:20px;" actionListener="#{userHome.click2}" update="part">
<h:outputText value="Send message" />
</p:commandLink>
<p:commandLink id="c3" style="margin-right:20px;">
<h:outputText value="Template Info" />
</p:commandLink>
<p:commandLink id="c4" style="margin-right:20px;">
<h:outputText value="Online status" />
</p:commandLink>
</h:panelGrid>
</h:form>
</ui:composition>

The center page1 is a simple xhtml file just show some words via outputText tag.

The center page2:data.xhtml(When clicking the top 2 command link on left page,this page will be loaded)
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:form id="dataForm">
<p:focus for="d"/>
<h:inputTextarea id="d" title="Please enter your message" value="#{userHome.data}" required="true" style="height:300px;width:800px"/>
<p:commandButton type="submit" value="Send" actionListener="#{userHome.saveText}" style="margin-right:20px;" update="msg d"/>
<h:outputText id="msg" value="#{userHome.message}" />
</h:form>
</ui:composition>

I just switched back to 2.2RC2,it worked fine.It should be a bug.

pacothegreko
Posts: 2
Joined: 01 Feb 2011, 21:07

08 Feb 2011, 18:23

Same problem with another components... wizard, datatable...

Try making redirect in every navigation case... and the controls work...

Then?????????????????????

nilonbarroso
Posts: 6
Joined: 08 Feb 2011, 21:04

08 Feb 2011, 22:10

I have the same problem. When I used the RC1 or RC2, everything worked fine.
I made no changes to the code. Just moved to version 2.2 final and then the problem occurred.

My environment:
Windows 7 64 bits,JBoss AS 6 (JEE6,CDI),PostgreSQL
Browser:FireFox 3.6.12 or Chrome 9

jenscb
Posts: 21
Joined: 03 Apr 2010, 20:15

08 Feb 2011, 22:38

Just a hint: Don't paste that much code in forums, as most readers will just ignore these posts, I haven't read that unformatted code either.
Use a pastebin service of your choice instead.

dbross
Posts: 9
Joined: 12 Aug 2010, 15:24

09 Feb 2011, 00:06

I am also seeing the first issue using primefaces 2.2 final. I have a menubar and a dialog in separate forms on my page. One of my top-level menu options invokes the dialog's show method. If I select this option first, I see the error. If I select another menu option which navigates to and renders a different page and then attempt to invoke the show dialog menu option, I don't see the error.

I had a custom navigation handler, action listener, and filter defined, and initially thought that the problem might be related to those, but the error still occurred after I removed them. My menu content is dynamically generated. I'm still investigating whether this makes a difference or not.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Feb 2011, 00:14

You need to provide a very simple code segment for us to replicate it. There will be 2.2.1 next week so it is now the best time to discuss these.

glister
Posts: 64
Joined: 19 Jan 2010, 11:39

09 Feb 2011, 10:18

same here after upgrading to 2.2 final. :cry:

Code: Select all

CHWERWIEGEND: javax.faces.FacesException: Unexpected error restoring state for component with id j_idt39.  Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
        at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:273)
        at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1485)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at com.sun.faces.component.visit.VisitUtils.doFullNonIteratingVisit(VisitUtils.java:75)
        at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:257)
        at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:181)
        at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:448)
        at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at filter.checkLoginFilter.doFilter(checkLoginFilter.java:196)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
        at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1432)
        at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:265)
        ... 47 more

SCHWERWIEGEND: javax.faces.FacesException: Unexpected error restoring state for component with id j_idt39.  Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
        at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:273)
        at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1485)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIForm.visitTree(UIForm.java:326)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496)
        at com.sun.faces.component.visit.VisitUtils.doFullNonIteratingVisit(VisitUtils.java:75)
        at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:257)
        at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:181)
        at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:448)
        at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at filter.checkLoginFilter.doFilter(checkLoginFilter.java:196)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
        at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1432)
        at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:265)
        ... 52 more
PrimeFaces version:
using Primefaces 5.2.11 on a Glassfish v4.1 Server

Additional Libraries:
using PrimeFaces Extensions 3.2
using OmniFaces 2.1

Additional Books:
PrimeFaces Cookbook

csyperski
Posts: 103
Joined: 16 Apr 2010, 14:36

10 Feb 2011, 03:17

I am having the same issue, but I also experience it in 2.2 RC 2.

2.2 RC 2/final
Mojarra 2.0.4
Tomcat 6

Here is a link to a post I made earlier.
http://primefaces.prime.com.tr/forum/vi ... f=3&t=7742

zbindere
Posts: 22
Joined: 02 Feb 2011, 17:20

10 Feb 2011, 14:18

OK, here a sample Page which is failing in 2.2 Final. It is basically the editable Datatable example from Showcase:

index.xhtml:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            <h:panelGrid columns="1">
                <h:commandLink value="datatable" action="datatable"/>
            </h:panelGrid>
        </h:form>
    </h:body>
</html>
datatable.xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:panelGroup style="width:50%" layout="block">
            <h:form id="form">

                <p:dataTable var="car" value="#{tableBean.carsSmall}" id="carList">

                    <f:facet name="header">
                        In-Cell Editing
                    </f:facet>

                    <p:column headerText="Model" style="width:150px">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{car.model}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{car.model}" style="width:100%"/>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="Year" style="width:150px">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{car.year}" />

                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{car.year}" style="width:100%" id="carInput" required="true">
                                    <f:validateLongRange minimum="1900" maximum="2010"/>
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="Manufacturer" style="width:150px">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{car.manufacturer}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:selectOneMenu value="#{car.manufacturer}" >
                                    <f:selectItems value="#{tableBean.manufacturers}"
                                                   var="man"
                                                   itemLabel="#{man}"
                                                   itemValue="#{man}" />
                                </h:selectOneMenu>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="Color" style="width:150px">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{car.color}" />
                            </f:facet>
                            <f:facet name="input">
                                <h:selectOneMenu value="#{car.color}" >
                                    <f:selectItems value="#{tableBean.colors}"
                                                   var="color"
                                                   itemLabel="#{color}"
                                                   itemValue="#{color}" />
                                </h:selectOneMenu>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="Options">
                        <p:rowEditor />
                    </p:column>
                </p:dataTable>
                <h:messages globalOnly="true"/>
                <h:message for="carInput"/>
                <h:message for="input"/>
            </h:form>
        </h:panelGroup>
    </h:body>
</html>
TableBean.java

Code: Select all

package org.example;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.example.model.Car;
import org.primefaces.event.UnselectEvent;

@ManagedBean(name = "tableBean")
@SessionScoped
public class TableBean implements Serializable {

    private final static String[] colors;
    private final static String[] manufacturers;
    private Car selectedCar;
    private List<Car> carsSmall;
    private String testString;

    static {
        colors = new String[10];
        colors[0] = "Black";
        colors[1] = "White";
        colors[2] = "Green";
        colors[3] = "Red";
        colors[4] = "Blue";
        colors[5] = "Orange";
        colors[6] = "Silver";
        colors[7] = "Yellow";
        colors[8] = "Brown";
        colors[9] = "Maroon";

        manufacturers = new String[10];
        manufacturers[0] = "Mercedes";
        manufacturers[1] = "BMW";
        manufacturers[2] = "Volvo";
        manufacturers[3] = "Audi";
        manufacturers[4] = "Renault";
        manufacturers[5] = "Opel";
        manufacturers[6] = "Volkswagen";
        manufacturers[7] = "Chrysler";
        manufacturers[8] = "Ferrari";
        manufacturers[9] = "Ford";
    }

    public TableBean() {
        carsSmall = new ArrayList<Car>();

        populateRandomCars(carsSmall, 9);
    }

    private void populateRandomCars(List<Car> list, int size) {
        for (int i = 0; i < size; i++) {
            list.add(new Car(getRandomModel(), getRandomYear(), getRandomManufacturer(), getRandomColor()));
        }
    }

    public List<Car> getCarsSmall() {
        return carsSmall;
    }

    private int getRandomYear() {
        return (int) (Math.random() * 50 + 1960);
    }

    private String getRandomColor() {
        return colors[(int) (Math.random() * 10)];
    }

    private String getRandomManufacturer() {
        return manufacturers[(int) (Math.random() * 10)];
    }

    private String getRandomModel() {
        return UUID.randomUUID().toString().substring(0, 8);
    }

    public String[] getManufacturers() {
        return manufacturers;
    }

    public String[] getColors() {
        return colors;
    }

    public Car getSelectedCar() {
        return selectedCar;
    }

    public void setSelectedCar(Car selectedCar) {
        this.selectedCar = selectedCar;
    }

    public void removeSelectedCar() {
        this.carsSmall.remove(this.selectedCar);
        this.selectedCar = null;
    }

    public void addCar() {
        this.carsSmall.add(0, new Car());
    }

    public void onRowUnselect(UnselectEvent event) {
        this.selectedCar = null;
    }

    public String getTestString() {
        return testString;
    }

    public void setTestString(String testString) {
        this.testString = testString;
    }
    
}
When I click the Link datatable form index.xhtml and then I edit a row I get:

Code: Select all

WARNING: Unable to find component with ID input in view.
SEVERE: javax.faces.FacesException: Unexpected error restoring state for component with id j_idt3.  Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
This was not the case with RC2.

csyperski
Posts: 103
Joined: 16 Apr 2010, 14:36

10 Feb 2011, 15:04

I have had luck with the 3.0 snapshot fixing this issue for me, does 3.0 work for anyone else????

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 47 guests