title: JSF: Validate value provided in both fields or none of them
body: <p>I have two fields representing data range ("from" and "to"). I need to check if either both fields are filled on none of them, so only moment there should be validation message shown is when one is filled and not second one. How can I do that? I thied this custom validator and add it to both fields (as JSF doesn't validate empty fields) but it always show that they are not valid.</p>
  
  <pre><code>public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    String otherControlId = (String) component.getAttributes().get("otherControlId");
    UIInput otherControlInput = (UIInput) context.getViewRoot().findComponent(otherControlId);
    Object otherControlValue = otherControlInput.getValue();
    if ((value == null &amp;&amp; otherControlValue != null) || (value != null &amp;&amp; otherControlValue == null)) {
   //show message
    }
  }
  </code></pre>
  
  <p>otherControlId points to second control ID, and I get a control in validator. But otherControlValue is always null.</p>