我有这样的事情:
<h:form id="form">
<p:fileUpload fileUploadListener="#{jSFmanageBean.fileUpload}"
update="gallery"
mode="advanced"
auto="true"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
<p:dataGrid var="car"
value="#{jSFmanageBean.cars}"
id="gallery" >
<p:panel header="#{car.id}"
style="text-align:center"
id="testSomething">
<p:graphicImage alt="ERROR2"
value="#{jSFmanageBean.image2}"
width="250">
<f:param name="id" value="#{car.id}" />
</p:graphicImage>
</p:panel>
</p:dataGrid>
<p:commandLink update=":form:carDetail"
oncomplete="PF('carDialog').show()"
title="View Detail">
<h:outputText styleClass="ui-icon ui-icon-search"
style="margin:0 auto;" />
<f:setPropertyActionListener value="#{car}"
target="#{jSFmanageBean.selectedCar}" />
</p:commandLink>
<p:dialog header="Car Info"
widgetVar="carDialog"
modal="true"
showEffect="fade"
hideEffect="fade"
resizable="false">
<p:outputPanel id="carDetail"
style="text-align:center;">
<p:panelGrid columns="2"
rendered="#{not empty jSFmanageBean.selectedCar}"
columnClasses="label,value">
<h:outputText value="Id:" />
<h:outputText value="#{jSFmanageBean.selectedCar.id}" />
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
问题是,当我尝试使用“p:commandLink”时,“p:fileUpload”组件被触发(或类似的东西)并且我有错误。
Warning: javax.servlet.ServletException: The request content-type is not a multipart/form-data
javax.faces.FacesException: javax.servlet.ServletException: The request content-type is not a multipart/form-data
at org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:44)
at org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:44)
.
.
.
Caused by: javax.servlet.ServletException: The request content-type is not a multipart/form-data
.
.
当我以相同的形式使用其他ajax时,如何防止触发FileUpload?
答案 0 :(得分:1)
当您点击p:commandLink
时,您正在处理整个表单,因为默认情况下是提交类型。在不了解您的目的的情况下,一种简单的方法就是将process="@this"
添加到p:commandLink
以避免处理表格的其余部分(如果您想要处理更多可以添加的内容) :
<p:commandLink update=":form:carDetail" process="@this"
oncomplete="PF('carDialog').show()"
title="View Detail">