title: Validating three dependent h:selectOneMenus
body: <p>i want to validate a jsf selectOne Menu:</p>
  
  <pre><code>&lt;h:selectOneMenu id="day" value="#{registerService.dayOfBirth}"&gt;
      &lt;f:selectItems value="#{registerService.days}" /&gt;
      &lt;f:validator validatorId="dateValidator" /&gt;
      &lt;f:attribute name="monthId" value="#{component.parent.parent.clientId}:month" /&gt;
      &lt;f:attribute name="yearId" value="#{component.parent.parent.clientId}:year" /&gt;
  &lt;/h:selectOneMenu&gt;
  
  &lt;h:selectOneMenu id="month" value="#{registerService.monthOfBirth}"&gt;
      &lt;f:selectItems value="#{registerService.months}" /&gt;
  &lt;/h:selectOneMenu&gt;
  
  &lt;h:selectOneMenu id="year" value="#{registerService.yearOfBirth}"&gt;
      &lt;f:selectItems value="#{registerService.years}" /&gt;
  &lt;/h:selectOneMenu&gt;
  </code></pre>
  
  <p>My Validator is this:</p>
  
  <pre><code>@FacesValidator(value="dateValidator")
  public class DateValidator implements Validator {
  
      public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
          String year = (String) component.getAttributes().get("yearId");
          String month = (String) component.getAttributes().get("monthId");
          UIInput yearInput = (UIInput) context.getViewRoot().findComponent(year);
          UIInput monthInput = (UIInput) context.getViewRoot().findComponent(month);
          FacesMessage message = null;
  
          int yearValue = (Integer) yearInput.getValue();
          int monthValue = (Integer) monthInput.getValue();
          int dayValue = (Integer) value;
  
          Calendar calendar = Calendar.getInstance();
          calendar.set(yearValue, monthValue, dayValue);
  
          int daysOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
  
          if (daysOfMonth &lt; dayValue) {
              message = new FacesMessage ("Date is not valid!", "Email Validation Error");
              message.setDetail("This month does not have so many days!");
              message.setSeverity(FacesMessage.SEVERITY_ERROR);
  
              throw new ValidatorException(message);
          }
      }
  }
  </code></pre>
  
  <p>And i get this error message:</p>
  
  <pre><code>java.lang.IllegalArgumentException: j_idt12
  at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:655)
  at de.hof.tschuwwa.controller.validators.DateValidator.validate(DateValidator.java:27)
  at javax.faces.component.UIInput.validateValue(UIInput.java:1165)
  at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:146)
  at javax.faces.component.UIInput.validate(UIInput.java:983)
  at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
  at javax.faces.component.UIInput.processValidators(UIInput.java:712)
  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
  at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
  at javax.faces.component.UIForm.processValidators(UIForm.java:253)
  at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:552)
  at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
  at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
  at javax.faces.component.UIForm.visitTree(UIForm.java:371)
  at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
  at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
  at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:399)
  at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:263)
  ... 32 more
  </code></pre>
  
  <p>So the exception is thrown here:</p>
  
  <pre><code>UIInput yearInput = (UIInput) context.getViewRoot().findComponent(year);
  </code></pre>
  
  <p>My other validators are all working but they arent with selectOneMenu they
  are with inputText.</p>