2

I'm using the following code to cause custom validators to skip validation on certain button presses :

<p:commandButton ... value="Don't Validate">
    <f:param name="triggerValidation" value="false"/>
</p:commandButton>

Which is working quite nicely. However I can't seem to get this to work when using the <p:fileDownload> component :

<p:commandButton ... value="Don't Validate">
    <p:fileDownload value="#{someWebBean.download()}">
        <f:param name="triggerValidation" value="false"/>
    </p:fileDownload>
</p:commandButton>

The triggerValidation parameter is null by the time it gets to the validator (regardless of whether the <f:param> element is a child of the <p:commandButton> or <p:fileDownload> component).

The code inside the base class of the custom validators get this parameter:

Object o = ((HttpServletRequest) context.getExternalContext().getRequest()).getParameter("triggerValidation");

Any insight into why this is happening would be greatly appreciated!

Tiny
  • 27,221
  • 105
  • 339
  • 599
StuPointerException
  • 7,117
  • 5
  • 29
  • 54
  • 1
    For one thing, `` can be applied only to children of `UIComponent`; `` is a tag handler. What you're attempting to do now is akin to trying to attach an `` to a ``. – kolossus Dec 09 '14 at 06:09

1 Answers1

0

Even if the p:commandButton contains the p:fileDownload, the parameter still has to be on the p:commandButton, not the p:fileDownload

<p:commandButton ... value="Don't Validate">
    <f:param name="triggerValidation" value="false"/>

    <p:fileDownload value="#{someWebBean.download()}" />
</p:commandButton>

See also How to pass a parameter along with h:commandButton.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
ltlBeBoy
  • 1,242
  • 16
  • 23