Question

I am trying to validate a field based on another field's value.

<h:form id="item">
  <s:validateAll/>
  <h:selectBooleanCheckbox id="selected" value="#{bean.selected}" validator="selectedValidator"/>
  <rich:calendar id="startDate" value="#{bean.startDate}"/>
</h:form>

However, inside my validator.

public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
  UIInput startComp = (UIInput) context.getViewRoot().findComponent("item:startDate");
  if(value != null && value) {
    // Check value of startComp and throw exception if null or empty.
  }
}

The component startComp resolves, but has no value. Where is the value that appears in the text box of the richfaces calendar component?

Was it helpful?

Solution

try this: item:startDatInputDate

OTHER TIPS

Please check value of startDate in your bean that is you used in the tag here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top