webtier@glassfish.java.net

Is PostValidateEvent really indicating that all validation has run

From: <webtier_at_javadesktop.org>
Date: Fri, 08 Jan 2010 07:50:00 PST

I'm trying the implement a component that triggers some component manipulation after a certain component has validated its submitted value (basically setting the style class based on the severity)

<h:inputText label="Amount" id="amount" required="true">
        <b:setStyleClassIfMessages for="amount" infoClass="validationInfo" warnClass="validationWarn" errorClass="validationError" fatalClass="validationFatal" />
</h:inputText>

As I found it a bit difficult to find the right UIComponent callback to hook into, I started an event based approach. I register for the PostValidateEvent to get notified about the finish of validation. However, I had to figure out that receiving this event does not really mean that validation is complete. As you see below, processValidators() is sending Pre/PostValidateEvent to its children by calling super.processValidators().

    public void processValidators(FacesContext context) {

        if (context == null) {
            throw new NullPointerException();
        }

        // Skip processing if our rendered flag is false
        if (!isRendered()) {
            return;
        }

        super.processValidators(context);
        if (!isImmediate()) {
            executeValidate(context);
        }
    }

But as you can see in the stack-trace, only later in validateValue(), validators are being called ???

HtmlInputText(UIInput).validateValue(FacesContext, Object) line: 1104
HtmlInputText(UIInput).validate(FacesContext) line: 941
HtmlInputText(UIInput).executeValidate(FacesContext) line: 1189
HtmlInputText(UIInput).processValidators(FacesContext) line: 691

JavaDoc from both event classes just add to this confusion it says "UIComponent that is about to bevalidated."

Thanks
[Message sent by forum member 'martinahrer' (martin.ahrer_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=379632