我有一个基于extendedDataTable的复合组件。我使用以下标签:
<composite:insertChildren />
在我的复合组件中允许用户插入extendedDataTable的列。这是我的组成部分:
<composite:interface>
<composite:attribute name="id" />
<composite:attribute name="value" />
<composite:attribute name="selection" />
<composite:attribute name="selectionMode" />
<composite:attribute name="targetIds" />
<composite:attribute name="readonly" />
<composite:attribute name="showViewButton" default="true"/>
<composite:attribute name="showEditButton" default="true"/>
<composite:attribute name="showDeleteButton" default="true"/>
<composite:attribute name="showSaveButton" default="true"/>
<composite:clientBehavior name="blur" event="blur" targets="#{cc.attrs.renderIds}" default="true"/>
<composite:attribute name="renderIds" />
<composite:attribute name="saveRenderIds" />
<composite:attribute name="deleteRenderIds" />
<composite:attribute name="viewRenderIds" />
<composite:attribute name="editRenderIds" />
<composite:attribute name="controller" />
<composite:attribute name="headerStr" />
<composite:attribute name="messagesGridId" required="true"/>
<composite:attribute name="viewButtonClick" />
</composite:interface>
<composite:implementation>
<h:outputStylesheet library="css" name="inlineEditGrid.css" />
<h:outputScript library="js" name="inlineEditGrid.js" target="head" />
<h:form id="inlineGridForm" >
<rich:extendedDataTable id="inlineEditGrid"
styleClass="inlineEditGrid" value="#{cc.attrs.value}"
var="currentRow" selection="#{cc.attrs.selection}"
selectionMode="#{cc.attrs.selectionMode}"
onready="prepareInlineGrid(this);"
rowKeyVar="rowKeyVar" rows="#{cc.attrs.controller.pageSize}">
<c:if test="#{!empty cc.getValueExpression('headerStr')}">
<f:facet name="header">
<h:outputText value="#{cc.attrs.headerStr}" />
</f:facet>
</c:if>
<a4j:ajax event="selectionchange" immediate="true"
listener="#{cc.attrs.controller.selectionListener}" render="#{cc.attrs.renderIds}"/>
<!-- Inserting columns provided by page author -->
<composite:insertChildren />
</rich:extendedDataTable></h:form>
以下是此组件的用法:
<ejadacomponents:inlineEditGrid id="masterGrid"
value="#{masterDetailController.dataModel}"
selection="#{masterDetailController.selection}" messagesGridId="messagesGrid"
selectionMode="#{masterDetailController.selectionMode}"
controller="#{masterDetailController}" viewButtonClick="#{rich:component('modalPanel')}.show();"
renderIds="detailGrid:inlineGridForm:inlineEditGrid ">
<rich:column width="200px">
<f:facet name="header">
<h:outputText value="#{msgs['masterLayoutPoc.deptNo']}" />
</f:facet>
<h:inputText value="#{currentRow.deptNo}" styleClass="disabledField creationOnly"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="#{msgs['masterLayoutPoc.deptName']}" />
</f:facet>
<h:inputText value="#{currentRow.dName}" id="dName" required="true" requiredMessage="this field is required ya ma3alem" render="messageField">
<f:ajax event="blur" execute="@this" />
</h:inputText>
<br/>
<h:message id="messageField" for="dName" title="this field is required ya ma3alem" />
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="#{msgs['masterLayoutPoc.deptLoc']}" />
</f:facet>
<h:inputText value="#{currentRow.loc}" />
</rich:column>
</ejadacomponents:inlineEditGrid>
但是在运行后我得到了这个例外:
javax.faces.FacesException: Unexpected error restoring state for component with id myForm:masterGrid:inlineGridForm:inlineEditGrid:dName. Cause: java.lang.ClassCastException: javax.faces.component.StateHolderSaver cannot be cast to [Ljava.lang.Object;.
at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:250)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:147)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1481)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at org.richfaces.component.UIDataAdaptor.visitComponents(UIDataAdaptor.java:1246)
at org.richfaces.component.UIDataAdaptor.visitDataChildren(UIDataAdaptor.java:1273)
at org.richfaces.component.UIDataTableBase.visitDataChildren(UIDataTableBase.java:395)
at org.richfaces.component.AbstractExtendedDataTable.visitDataChildren(AbstractExtendedDataTable.java:156)
at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1347)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at javax.faces.component.UIForm.visitTree(UIForm.java:331)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:159)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at javax.faces.component.UIForm.visitTree(UIForm.java:331)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1492)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:234)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:177)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:119)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:438)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:144)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:284)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:284)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:183)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
如果我删除这个ajax标签,一切都很好:
<f:ajax event="blur" execute="@this" />
我的代码有问题吗?
谢谢和最诚挚的问候,
巴萨姆