0

I am trying to add a request parameter to an advanced primefaces p:fileUpload. I try to do this in order to check for this parameter in a Servlet.Filter. Using f:param with a simple p:fileUpload mode="simple" works fine:

<h:form enctype="multipart/form-data">
    <p:fileUpload value="#{myBean.file}" mode="simple" skinSimple="true"/>
    <p:commandButton value="Submit" ajax="true" action="#{myBean.upload}">
        <f:param name="doStuffInFilter" value="true"/>
    </p:commandButton>
</h:form>

However, i can not get this to work with the p:fileUpload mode="advanced" Component to work:

<h:form enctype="multipart/form-data">
    <p:fileUpload id="fileUploadPrimefaces1" listener="#{myBean.handleFileUpload}" 
                  mode="advanced" dragDropSupport="true" ... />
</h:form>

What i tried:

  1. Add f:param to p:fileUpload -> does not seem to have any effect
  2. Based on this Stackoverflow Answer, I tried to add the param to the request using the Primefaces ClientAPI like this:
<p:fileUpload mode="advanced" ... onstart="this.cfg.ext={params: [name: 'doStuffInFilter', value: 'true']}" />

While I could see that the value was set using the browser dev tools, the HttpServletRequest did not contain the parameter on serverSide. Do you have any Idea how to solve this?

F. Zi
  • 41
  • 8
  • Just out of curiosity, what is the stuff you want to do in the filter? – Jasper de Vries May 09 '22 at 14:30
  • @JasperdeVries The short anwser is: Disable another filter. The long one: I am working with a legacy application which uses the Tomahawk ExtensionFilter. Unfortunatly, it prevents the Primefaces fileUpload and removing it is currently not an option. Disabling the filter for Primefaces fileUploads seems to be the best interim solution. – F. Zi May 10 '22 at 06:07

0 Answers0