title: How to mark other components invalid in a custom multi-field validator
body: <p>I refer to one of BalusC's answers:
  <a href="https://stackoverflow.com/questions/6282466/jsf2-0-doesnt-support-cross-field-validation-is-there-a-workaround">JSF doesn&#39;t support cross-field validation, is there a workaround?</a></p>
  
  <p>I follow the same way, and come out with code as below:</p>
  
  <p>in .xhtml</p>
  
  <pre><code>&lt;h:form id="form1"&gt;
    &lt;div&gt;
      &lt;p:messages globalOnly="true" display="text" /&gt;
  
          &lt;h:inputHidden value="true"&gt;
              &lt;f:validator validatorId="fooValidator" /&gt;
              &lt;f:attribute name="input1" value="#{input1}" /&gt;
              &lt;f:attribute name="input2" value="#{input2}" /&gt;
              &lt;f:attribute name="input3" value="#{input3}" /&gt;
          &lt;/h:inputHidden&gt;
  
          &lt;h:panelGrid columns="3"&gt;  
              &lt;h:outputText value="name 1: " /&gt;
              &lt;p:inputText binding="#{input1}" id="input11" value="#{testPage.input1}" /&gt;
              &lt;p:message for="input11" display="text"/&gt;
          &lt;/h:panelGrid&gt;
          &lt;h:panelGrid columns="3"&gt;
              &lt;h:outputText value="name 2: " /&gt;               
              &lt;p:inputText binding="#{input2}" id="input22" value="#{testPage.input2}" /&gt;
              &lt;p:message for="input22" display="text"/&gt;
          &lt;/h:panelGrid&gt;
          &lt;h:panelGrid columns="3"&gt;
              &lt;h:outputText value="name 3: " /&gt;
              &lt;p:inputText binding="#{input3}" id="input33" value="#{testPage.input3}" /&gt;
              &lt;p:message for="input33" display="text"/&gt;
          &lt;/h:panelGrid&gt;
          &lt;p:commandButton value="Submit" action="#{testPage.submitValidator}" update=":updateBody" /&gt;
      &lt;/div&gt;
  
  &lt;/h:form&gt;
  </code></pre>
  
  <p>java class:</p>
  
  <pre><code>@FacesValidator(value="fooValidator")
  public class CustomValidator2 implements Validator {
  
      @Override
      public void validate(FacesContext context, UIComponent component, Object value)
          throws ValidatorException {
      UIInput input1 = (UIInput) component.getAttributes().get("input1");
      UIInput input2 = (UIInput) component.getAttributes().get("input2");
      UIInput input3 = (UIInput) component.getAttributes().get("input3");
  
      Object value1 = input1.getSubmittedValue();
      Object value2 = input2.getSubmittedValue();
      Object value3 = input3.getSubmittedValue();
  
      if (value1.toString().isEmpty() &amp;&amp; value2.toString().isEmpty() &amp;&amp; value3.toString().isEmpty()) {
          String errorMsg = "fill in at least 1";
          FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMsg, errorMsg);
          FacesContext.getCurrentInstance().addMessage("form1:input11", msg);
          //throw new ValidatorException(msg);
      }
  
      }
  }
  </code></pre>
  
  <p>the code is working fine, but i face a problem. How to highlight border of name1 inputText(or both name1 and name2 inputText) with red color as usually done by JSF when validation fails.</p>
  
  <p>image as reference:
  <a href="http://img443.imageshack.us/img443/8106/errork.jpg" rel="nofollow noreferrer">http://img443.imageshack.us/img443/8106/errork.jpg</a></p>
  
  <p>thanks in advance</p>