簡體   English   中英

Primefaces帶有MobileRenderKit的高級FileUpload

[英]Primefaces advanced FileUpload with MobileRenderKit

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

謝謝

看一下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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM