将请求param添加到PrimeFaces高级FileUpload

发布于 2025-01-27 11:18:14 字数 1249 浏览 2 评论 0原文

我正在尝试将请求参数添加到高级PrimeFaces p:fileupload。我尝试这样做以在servlet.filter中检查此参数。使用f:param带有简单p:fileupload模式=“ simple”正常工作:

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

但是,我无法使其与p:fileupload模式使用=“高级”要工作的组件:

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

我尝试过的:

  1. add f:param to p:fileupload - &gt;似乎没有
  2. 基于 stackoverflow答案的 效果:
<p:fileUpload mode="advanced" ... onstart="this.cfg.ext={params: [name: 'doStuffInFilter', value: 'true']}" />

虽然我可以看到该值是使用浏览器开发工具设置的,但httpservletrequest不包含服务器上的参数。您知道如何解决这个问题吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文