2014-03-26 67 views
0

我使用Primefaces4.0和JSF2.0,我知道Primefaces的一些基础知识。 对我来说p:fileUpload不工作,它以前工作。不知道发生了什么 当我从文件选择器中选择任何文件时,没有文件在p:fileUpload文件中填充。Primefaces p:fileUpload不起作用

这里是我的代码:

<p:panel style="font-size:15px;" header="Upload"> 
    <p:fileUpload fileUploadListener="#{addAgentxls.handleFileUpload}" mode="advanced" dragDropSupport="true" 
        update="messages status" sizeLimit="100000" style="font-size:12px;" /> 
    <p:growl id="messages" showDetail="true"/> 
    <p:outputLabel id="status" style="font-size:13px;" value="#{addAgentxls.status }"/> 
</p:panel> 

类文件:

@ManagedBean(name = "addAgentxls", eager = true) 
@SessionScoped 
public class AddAgentUsingXLS { 
    public AddAgentUsingXLS(){ 
    } 
    public void handleFileUpload(FileUploadEvent event) { 
      FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded."); 
      FacesContext.getCurrentInstance().addMessage(null, msg); 
     } 
} 

的web.xml:

<!-- File Uploading Constraints --> 
<filter> 
    <filter-name>PrimeFaces FileUpload Filter</filter-name> 
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>PrimeFaces FileUpload Filter</filter-name> 
    <servlet-name>Faces Servlet</servlet-name> 
</filter-mapping> 

我也看到This为我做什么 有错误在谷歌C​​hrome浏览器上

Uncaught TypeError: Object [object Object] has no method 'fileupload' 
fileupload.js.xhtml?ln=primefaces&v=4.0:1 

它值得吗?

+0

我不确定您是否已将enctype =“multipart/form-data”添加到您的表单中。 – psi

+0

是面板添加在h:表格 – Sarz

+1

请参阅http://stackoverflow.com/questions/16166039/uncaught-typeerror-cannot-read-property-value-of-undefined-using-primefaces-f/16168985#16168985 – psi

回答

1

解决..!我正在使用jQuery.js的较新版本,它与Primefaces

0

冲突请考虑关于以下堆栈溢出链接的建议。

In JavaScript can I make a "click" event fire programmatically for a file input element?

同样的问题。 jQuery(“。primeFacesHiddenAwayButton type = ['file']”)。click()在IE以及firefox上都能正常工作(由于Selenium驱动程序的限制,我的Firefox不是最新的)。在任何情况下,在JS中,JS按钮都不起作用。显然,这是浏览器内置的安全功能。您可以尝试提供的链接上的建议。

相关问题