Primefaces使用MobileRenderKit进行高级FileUpload

时间:2015-06-12 06:50:20

标签: jsf mobile primefaces primefaces-mobile

Advanced FileUpload是否适用于MobileRenderKit?

我尝试使用以下代码上传:

upload.xhtml:

   <h:form  enctype="multipart/form-data"
      rendered="#{eordner.uploadaktiv}">
      <p:fileUpload id="dateiupload" fileUploadListener="#{upload.getfiles}">
      </p:fileUpload>
      <p:commandButton value="Hochladen..." />
   </h:form>

uploadbean.java:

  public void getfiles(FileUploadEvent event) {

      System.out.println(event.getFile().getFileName());

   }

但是永远不会调用fileUploadListener。

当我改为正常的RenderKit时,它会被调用。

有解决方案吗?我希望能够进行多次上传。

简单模式正常工作

我在 Primefaces 5.2 Tomat 7.0.26 Java 1.0.7 Mojarra 2.2.10

由于

1 个答案:

答案 0 :(得分:1)

查看PF移动FileUpload源代码:

protected void encodeInputField(FacesContext context, FileUpload fileUpload, String clientId) throws IOException {
    ResponseWriter writer = context.getResponseWriter();

    writer.startElement("input", null);
    writer.writeAttribute("data-role", "none", null);
    writer.writeAttribute("type", "file", null);
    writer.writeAttribute("name", clientId, null);

    if(fileUpload.isMultiple()) writer.writeAttribute("multiple", "multiple", null);
    if(fileUpload.getStyle() != null) writer.writeAttribute("style", fileUpload.getStyle(), "style");
    if(fileUpload.getStyleClass() != null) writer.writeAttribute("class", fileUpload.getStyleClass(), "styleClass");
    if(fileUpload.isDisabled()) writer.writeAttribute("disabled", "disabled", "disabled");

    writer.endElement("input");
}

,表示不支持高级模式,但multiple属性为。

请尝试使用multiple="true"