当ajax打开时,Primefaces命令按钮停止fileupload [英] Primefaces command buttons stopping fileupload when ajax is on
问题描述
< p:commandButton action =#{userBean .buttonToUploadText}value =Submiticon =ui-icon-arrowstop-1-n/>
userBean.java
public String buttonToUploadText(){
System.out.println(buttonToUploadText invoked); //测试以确保它被称为
返回/upload/uploadText.xhtml;
}
这一切应该做的仅仅是把用户带到上传文本页面,做到这一点,但每当我有这个按钮fileupload什么也不做,但第二我编辑这个命令按钮,并使用正常的文件上传工作完美?我在做什么错误
编辑:
刚刚发现,当ajax是假的,它完美的作品,为什么如果你的PrimeFaces文件上传组件有一个这样的代码,但是这个问题是可以识别的模式= 简单
。这将生成一个没有任何JS / Ajax支持的本地HTML < input type =file>
。这需要一个带有 ajax =false
的命令按钮,完全如 showcase 。
如果您希望能够通过ajax上传文件并提交表单, code>模式= 高级。另请参阅展示。
另见:
got a weird issue, i have a primefaces command button :
<p:commandButton action="#{userBean.buttonToUploadText}" value="Submit" icon ="ui-icon-arrowstop-1-n"/>
userBean.java
public String buttonToUploadText() {
System.out.println("buttonToUploadText invoked"); //testing to make sure it is called
return "/upload/uploadText.xhtml";
}
all this should do is simply take the user to the upload text page, it does this but whenever i have this button the fileupload does nothing, but the second i edit this command button out and use a normal one the file upload works perfect ? what am i doing wrong
EDIT:
have just found out when ajax is false it works perfectly, why is this ?
You didn't show all the code, but this problem is recognizable if your PrimeFaces file upload component has a mode="simple"
. This will generate a native HTML <input type="file">
without any JS/Ajax support. This requires a command button with ajax="false"
, exactly as shown in the showcase.
If you want to be able to upload files and submit the form by ajax, then use mode="advanced"
. See also the showcase.
See also:
这篇关于当ajax打开时,Primefaces命令按钮停止fileupload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!