How to mark other components invalid in a custom multi-field validator

前端 未结 1 2011
忘掉有多难
忘掉有多难 2021-01-05 11:00

I refer to one of BalusC\'s answers: JSF doesn't support cross-field validation, is there a workaround?

I follow the same way, and come out with code as below:

相关标签:
1条回答
  • 2021-01-05 11:46

    Mark them invalid by UIInput#setValid(), passing false.

    input1.setValid(false);
    input2.setValid(false);
    input3.setValid(false);
    

    The borders are specific to PrimeFaces <p:inputText>, so you don't need to add any CSS boilerplate as suggested by the other answerer.

    Note that this can also be achieved by OmniFaces <o:validateAll> tag without the need to homegrow a custom validator.

    0 讨论(0)
提交回复
热议问题