1

Advanced FileUpload 是否适用于 MobileRenderKit?

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

上传.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>

上传bean.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

谢谢

4

1 回答 1

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

于 2015-06-12T07:59:01.283 回答