jsf - 复合:clientBehavior ==> NotSerializableException: com. sun.faces.facelets.tag.jsf.core.AjaxHandler

标签 jsf glassfish java-ee-6 composite-component

我对 JSF 还很陌生,想要构建一个复合组件来导出可以从复合组件用户处 ajax 的事件。

按照 http://www.ibm.com/developerworks/java/library/j-jsf2fu-0610/index.html 中的说明进行操作我使用了composite:clientBehavior,如下所示:

<composite:interface>
    <composite:attribute name="value" required="true"/>
    <composite:attribute name="selection" required="true"/>

[.... some other composite:attributes]

    <composite:facet name="header"/>

    <composite:clientBehavior name="rowSelect" event="rowSelect" default="true" targets="#{cc.clientId}:cmpntVideos"/>

</composite:interface>

<composite:implementation>
    <h:outputStylesheet library="css" name="VideoStatusTable.css" target="head" />

    <div id="#{cc.clientId}">
    <p:contextMenu for="cmpntVideos">
        <p:menuitem value="#{cc.resourceBundleMap.VideoStatusTable_contextual_menu_edit}" icon="menu-edit"/>
        <p:menuitem value="#{cc.resourceBundleMap.VideoStatusTable_contextual_menu_delete}" icon="menu-delete"/>
        <p:menuitem value="#{cc.resourceBundleMap.VideoStatusTable_contextual_menu_abort}" icon="menu-abort"/>
        <p:menuitem value="#{cc.resourceBundleMap.VideoStatusTable_contextual_menu_reenable}" icon="menu-reenable"/>
    </p:contextMenu>

    <p:dataTable id="cmpntVideos" var="video" value="#{cc.attrs.value}" rowKey="#{video.key}"
        selection="#{cc.attrs.selection}" selectionMode="single" emptyMessage="#{cc.attrs.emptyValueListMsg}">

        <composite:insertFacet name="header"/>

        <p:column headerText="#{cc.resourceBundleMap.VideoStatusTable_contextual_table_title_video_id}" rendered="#{cc.attrs.showRoadName}">
            #{video.humanReadableVideoId}  
        </p:column>

[.... many other column declaration]

        <p:column headerText="#{cc.resourceBundleMap.VideoStatusTable_contextual_table_title_report_generation}" rendered="#{cc.attrs.showReportGeneration}" style="text-align: center;">
            <f:facet name="header">
                <h:graphicImage library="images" name="documents_24.png"/>
            </f:facet>
            <cmpnt:simpleProgressBar value="#{video.reportGenerationProgress}"/>
        </p:column>

        <f:facet name="footer">
            <h:commandLink action="cc.attrs.refreshListener" style="float:right;">
                <h:graphicImage library="images" name="button-rotate-cw_16.png"/>
                <f:ajax render="cmpntVideos" execute="@this"/>
            </h:commandLink>
        </f:facet>

    </p:dataTable>
    </div>

</composite:implementation>

并按以下方式使用该组件:

        <cmpnt:videoStatusTable id="VideoTransferStatusTable"
                value="#{videoTransfer.tableModel}" 
                selection="#{videoTransfer.selectedTableReadyNotCompletelyTranferedVideo}"
                showProcess="false"
                showReportGeneration="false"
                showValidation="false"
                showDataOrganization="false"
        >
            <f:ajax event="rowSelect" listener="${videoTransfer.onVideoSelection}" render=":msgsArea"/>
        </cmpnt:videoStatusTable>

但是当我运行这个(并选择一行,这会触发 rowSelect 事件)时,我收到以下异常:

SEVERE: Error Rendering View[/private/AssetManager.xhtml]
javax.faces.FacesException: java.io.NotSerializableException: com.sun.faces.facelets.tag.jsf.core.AjaxHandler
    at com.sun.faces.renderkit.ResponseStateManagerImpl.getViewState(ResponseStateManagerImpl.java:137)
    at javax.faces.application.StateManager.getViewState(StateManager.java:555)

[...]

Caused by: java.io.NotSerializableException: com.sun.faces.facelets.tag.jsf.core.AjaxHandler
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
    at java.util.ArrayList.writeObject(ArrayList.java:570)

[...]

WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: CDATA tags may not nest
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:630)
    at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:172)

当我删除 ajax 标签时,该组件工作正常(尽管没有某些功能)。

我使用 Glassfish 3.1.2。谁能帮我理解这里发生了什么?

谢谢

最佳答案

看起来已经有一个 jira-issue为此。

关于jsf - 复合:clientBehavior ==> NotSerializableException: com. sun.faces.facelets.tag.jsf.core.AjaxHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11781411/

相关文章:

java - 使用 Guice 的 @Inject 注入(inject) @Context 字段(到子资源中)

jsf - p :commandLink won't redirect to new page?

JPA Glassfish 数据库更新问题

java - 如何为多个对象制作表单输入字段?

java - 使用 MyFaces Tomahawk + ​​JSF 2.0 上传文件

java - Resource.properties 文件中的多行值?

java - 请求的资源不可用 Glassfish 4

java - 在主页中,当我们导航到另一个页面并返回主页时,返回用户名时出现错误

tomcat - 如何使用 tomcat 的 catlina api 访问 session 管理

JSF Bootsfaces 组件未显示