1
votes

Does Advanced FileUpload work with MobileRenderKit?

I tried to Upload with following Code :

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());

   }

But the fileUploadListener is never invoked.

When I change to normal RenderKit it get invoked.

Is there a solution? I want to able to make mutiple upload.

The simple mode Works fine

I`m on Primefaces 5.2 Tomat 7.0.26 Java 1.0.7 Mojarra 2.2.10

Thanks

1
The simple mode works fine, but only for one filesuskun52
In PF Mobile 6, advanced mode still doesn't invoke its listener. If activated by a button, it just redirects back to the page without calling the button's ActionListener. Also, simple mode seems to not validate required field, file size and extension.Douglas De Rizzo Meneghetti

1 Answers

1
votes

Having a look at the PF mobile FileUpload source code:

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");
}

, tells that the advanced mode is not supported, but the multiple attribute is.

So try with multiple="true".