0

This is the short code:

<p:selectOneMenu id="field2" 
                ...
                 required="#{empty param[submit.field1]}">
    <p:ajax listener="#{test.onField2Change}" event="change" .../>
    ...
</p:selectOneMenu>

Problem is that when field2 is null and field1 is null I receive an error because the required field is not selected and the listener is no longer triggered.

I want the listener to trigger, how can I do this, or what are my other options? I already tried valueChangeListener and onchange instead but the problem is the same.

Victorqedu
  • 484
  • 4
  • 20
  • 1
    You could remove the required and check the value server-side, on form submit. – WoAiNii May 09 '21 at 09:12
  • 3
    See BalusC's response to the question [When to use valueChangeListener or f:ajax listener?](https://stackoverflow.com/questions/11879138/when-to-use-valuechangelistener-or-fajax-listener). In this case you may need to write a custom validator method instead of using `required`. – Brooksie May 09 '21 at 11:07

0 Answers0