【问题标题】:fileUpload not working in primefaces wizardfileUpload 在 primefaces 向导中不起作用
【发布时间】:2013-10-09 10:31:21
【问题描述】:

在 p:wizard 中,我在第一个选项卡中上传了文件。当我移至下一个选项卡时,上传的图像为空。如何解决此问题以在第一个选项卡中设置图像。请任何人帮助我... .......

<p:wizard>
    <p:tab id="tabbranch" title="Branch" titleStyle="font-size:14px;">  
        <p:panel id="display" >
            <h:panelGrid columns="2">
                <h:outputLabel value="Branch File" 
                    style="text-align: left;display: block;width:120px"/>
                <p:fileUpload value="#{branchBean.current.buildingPlan}" 
                    allowTypes="*.jpg;*.png;*.gif;" mode="simple" style="width:185px"/>     
            </h:panelGrid>  
        </p:panel>
    </p:tab>

    <p:tab title="Profile page 1" titleStyle="font-size:14px;">
        <p:panel>                   
            <h:outputLabel value="Name:*" style="text-align: left;display: block;width:130px;"/>
            <p:inputText value="#{branchBean.current.branchName}"
                readonly="#{searchBean.selectedCustomer.editAccess}"
                style="width:170px;" />
        </p:panel>
    </p:tab>
</p:wizard>

【问题讨论】:

  • 您使用的是哪些 primefaces 和 JSF 版本?
  • 我正在使用 primefaces 展示和版本 primefaces-3.5
  • 你的监听方法在哪里?请参考showcase use
  • 我在第一个选项卡中上传了文件,如果单击下一个选项卡,选择任何图像后,所选图像已消失/刷新。所以我没有在我的托管 bean 中获得 fileupload 的值。

标签: jsf file-upload primefaces


【解决方案1】:

来自 PrimeFaces 用户指南 3.5 (http://primefaces.googlecode.com/files/indexed_primefaces_users_guide_3_5.pdf):

1) 将以下库添加到您的项目中:commons-fileupload 1.2.1 和 commons-io 1.4;

2) 在您的 web.xml 中映射以下过滤器:

<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>

Primefaces 用户指南中未解释:

1) 将您的 h:form 配置为 multipart/form-data

<h:form enctype="multipart/form-data">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 2015-08-05
    • 2012-05-28
    • 2012-11-08
    • 2023-04-10
    • 1970-01-01
    相关资源
    最近更新 更多