Primefaces 正在删除上载的文件
我使用以下代码删除使用primefaces上传的文件Primefaces 正在删除上载的文件,primefaces,Primefaces,我使用以下代码删除使用primefaces上传的文件 <p:column width="35" headerText="Delete" style="text-align:center"> <h:commandLink ajax="true" update="@form" title="Delete Document" process="@form" action="#{learningGuaranteeBean.deleteDocument()}"
<p:column width="35" headerText="Delete" style="text-align:center">
<h:commandLink ajax="true" update="@form" title="Delete Document"
process="@form" action="#{learningGuaranteeBean.deleteDocument()}"
disabled="#{(learningGuaranteeBean.activeEntry.statusCode ne 3) and (learningGuaranteeBean.activeEntry.statusCode ne null)}">
<f:setPropertyActionListener
target="#{learningGuaranteeBean.selectedDocument}"
value="#{doc}"></f:setPropertyActionListener>
<h:graphicImage value="../images/icons/delete.gif"></h:graphicImage>
</h:commandLink>
</p:column>
但是,当我删除一个附加文件时,整个jsf页面都会重新加载,因此当我删除附加文件时,输入字段中输入的数据就会消失。有谁能帮我防止这种情况发生吗?您似乎错误地使用了
h:commandLink
而不是p:commandLink
。由于h:commandLink
甚至没有进程
、更新
、ajax
属性,因此会导致非ajax提交,因此会重新加载页面
使用p:commandLink
如果出于某种原因需要
h:commandLink
,则用错误的属性替换适当的f:ajax
标记。这与问题无关,但对于现代EL版本,您不需要f:setPropertyActionListener
。您只需将一个参数传递给操作方法:action=“#{learningguarantebean.deleteDocument(doc)}”
。