views:

1224

answers:

2

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?

A: 

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

Umesh Aawte
it's null, because it hasn't been set yet. Seam/jsf is on its way there when the validator picks up.
JBristow
A: 

try this: "item:startDatInputDate".

Ken
It's been so long since I posted this, I solved it without using a validator (a bit of a hack, I know). I'll try this the next chance I get though, and if it works, you'll get credit and an upvote. I have not forgotten!
JBristow