【问题标题】:Cannot set content type. Response already committed (jsf, primefaces)无法设置内容类型。响应已经提交(jsf,primefaces)
【发布时间】:2014-04-28 08:13:28
【问题描述】:

我正在尝试在 p:dialog 中加载一些数据,但出现“无法设置内容类型。响应已提交”错误,并且对话框中的数据未显示。而且“selectedGift”值始终为 null ..

这是我的 xhtml .. 有什么想法吗?

    <h:form id="giftForm">

        <p:dataGrid var="gift" value="#{AvailableGiftsView.gifts.giftType}" columns="3"  
    rows="12" >  

    <p:panel header="#{gift.nameAr}" style="text-align:center">  
        <h:panelGrid columns="1" style="width:100%">  


            <h:outputText value="#{gift.descriptionAr}" />  
            <p:commandLink  update=":giftForm:giftDetail" onclick="giftDialog.show()" title="View Detail">  
                <p:graphicImage value="#{gift.photoUrl}"/>   
                <f:setPropertyActionListener value="#{gift}"   
                        target="#{AvailableGiftsView.selectedGift}" />  
            </p:commandLink>  

        </h:panelGrid>  
    </p:panel>  

</p:dataGrid>  

 <p:dialog id="dlg" header="Gift Detail" widgetVar="giftDialog" modal="true">  
    <h:outputText value="Resistance to PrimeFaces is futile!" />  
    <p:outputPanel id="giftDetail" style="text-align:center;"> 
     <h:panelGrid  columns="2" cellpadding="5">  
            <h:outputLabel for="giftName" value="Gift Name " />  
            <h:outputText id="giftName" value="#{AvailableGiftsView.selectedGift.name}" />  

            <h:outputLabel for="costPoints" value="Points: " />  
            <h:outputText id="costPoints" value="#{AvailableGiftsView.selectedGift.pointsCost}" />  

            <h:outputLabel for="description" value="Description: " />  
            <h:outputText id="description" value="#{AvailableGiftsView.selectedGift.name}"/>  
        </h:panelGrid> 
    </p:outputPanel> 
</p:dialog>  
    </h:form>

</f:view>
</h:body>

【问题讨论】:

  • 通常这个异常是由于之前在一些ajax调用中的异常。您会在显示之前检查服务器日志是否有异常?
  • 不,这就是我得到的全部.. [4/28/14 15:08:38:006 GMT+02:00] 00000084 SystemOut O 2014-04-28 15:08:38 调试 RequestLogWrapper :50 - 设置区域设置 :: en [4/28/14 15:08:38:020 GMT+02:00] 00000084 ServletExtern E 无法设置内容类型。响应已提交

标签: jsf primefaces rad websphere-portal websphere-8


【解决方案1】:

好吧,将近 4 天后,我发现了问题所在.. 问题是我正在使用 RAD 8.5 和 Websphere 门户 8.0 .. 在创建我的 portlet 时,它是在 JSR 168 上创建的,所以 portlet.xml 如下

http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" id="com.ibm.faces.portlet.FacesPortlet.2a8361a544">

如您所见,它使用架构版本 1.0

当我将其更改为时

http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" id="com.ibm.faces.portlet.FacesPortlet.2a8361a544">

效果很好!

我希望它对那里的人有所帮助.. 整个问题是 portlet 版本与 AJAX 类型的请求不兼容...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 2015-03-10
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    相关资源
    最近更新 更多