0 Replies Latest reply: Nov 9, 2012 6:49 AM by 905019 RSS

    Cross fieldish validation

    905019
      So I have an ICEfaces tree component and using an input field with a value="#{_node.userObject.product.orderAmount}". If I connect a JSR-303 validator to the field, it's correctly evaluated. The problem is that I would need to validate against fields minOrderAmount and maxOrderAmount in the same Product object. I've registered a TYPE level validator on Product but that one isn't called when setting the value. The JSF2 spec delegates the validation integration to the Bean Validation spec and it only says it should call "bound validators" but apparently TYPE-level don't count (unless you have @Valid from the beginning of the chain?).

      So now I have a solution from http://stackoverflow.com/questions/6282466/jsf2-0-doesnt-support-cross-field-validation-is-there-a-workaround but $DEITY knows there's already enough components in my three without throwing in hidden dummy-fields.

      I also tried binding the Product to another hidden field with an objectConverter and a custom validator but it got schitzofrenic, not seeing the new value, overwriting with the old one etc. Not that surprising.

      Any theories on how to do this object level (or cross-field) validation thing with Bean Validation / JSF 2?

      Thanks in advance,
      Nik

      Edited by: Nik on Nov 9, 2012 4:48 AM