0

I have a big form on a JSF page using lots of components (PrimeFaces). They are using different validations (like min size/max size, patterns or even custom), but some of them are marked as required using required="true" or the requiredValidator.

I want to add a new commandButton to submit the form and do all the validation except the different require validations so that a missing input is ok but not a wrong format.

As for now, I don't see how this could be handled in JSF and I hope someone could give me a hint or something to find a way to implement this.

bdkosher
  • 5,753
  • 2
  • 33
  • 40
JMNO
  • 11
  • 1
  • Does any of the links here help: https://www.google.nl/search?q=conditionally+required+validator+jsf – Kukeltje Jul 03 '16 at 21:40
  • What is `requiredValidator` ? Do you mean 'requiredMessage'? – Mikhail Chibel Jul 03 '16 at 22:56
  • No can't do either skip the whole validation phase using ``immediate=true`` or add a listener to skip required validation before validation phase starts. – Youans Jul 04 '16 at 00:27
  • Thanks, after reading mor on these, I realized I can use something like this: required="#{not empty param[componentName.clientId]}". But this is a problem if the InputComponent is included from a different xhtml to different views. In some of them the "componentName" (commandButton) may not exist so it will fail. what is a way to avoid this? Hard coding this seems to me not good ... – JMNO Jul 07 '16 at 00:16

1 Answers1

0

To skip required validation completely you can set immediate=true on the button. If you want some of the element gets validated but some skipped, then use conditional 'required' as explained in this question.

Community
  • 1
  • 1
Mikhail Chibel
  • 1,865
  • 1
  • 22
  • 34