Mark Estrada
Mark Estrada

Reputation: 9201

Omnifaces ValidateEqual Does not perform validation

I am trying out the Omnifaces validators especially the validateEqual and so I created a test page such as this.

<p:messages autoUpdate="true" showDetail="false" />
<h:form id="registerForm" prependId="false">
    <p:panelGrid columns="2" styleClass="register-grid">

        <h:outputLabel for="password" value="Password *" />
        <p:inputText id="password" value="" label="Password"
            requiredMessage="Password is required" size="30">
            <f:validateRequired />
        </p:inputText>

        <h:outputLabel for="confirmPassword" value="Confirm Password *"
            requiredMessage="Confirm Password is required" />
        <p:inputText id="confirmPassword" value="" label="Confirm Password" requiredMessage="Confirm password is required"
            size="30">
            <f:validateRequired />
        </p:inputText>

        <o:validateEqual components="password confirmPassword" message="Passwords are not equal"/>

        <f:facet name="footer">
            <p:commandButton value="Register" action="/pages/public/login"/>
            <p:commandButton value="Cancel" immediate="true" action="/pages/public/login"/>
        </f:facet>
    </p:panelGrid>
</h:form>

Not sure but nothing is happening and I see from firebug below error.

<partial-response>
    <error>
        <error-name>class javax.faces.component.UpdateModelException</error-name>
        <error-message>/pages/public/register.xhtml @26,57 value="": Illegal Syntax for Set Operation</error-message>
    </error>
    <changes>
        <extension ln="primefaces" type="args">{"validationFailed":true}</extension>
    </changes>
</partial-response>

What could be the cause?

Upvotes: 1

Views: 497

Answers (1)

BalusC
BalusC

Reputation: 1109625

/pages/public/register.xhtml @26,57 value="": Illegal Syntax for Set Operation

This is basically telling that it's not possible to perform a "set" operation (a setter method call) on an empty value expression.

Either remove the value attribute altogether (at least from the "confirm" field), or specify a valid value expression such as value="#{bean.password}" (at least for the first field). So, basically:

<p:inputText id="password" value="#{bean.password}" label="Password"
    requiredMessage="Password is required" size="30" required="true" />
<p:inputText id="confirmPassword" label="Confirm Password" 
    requiredMessage="Confirm password is required" size="30" required="true" />
<o:validateEqual components="password confirmPassword" 
    message="Passwords are not equal" />

This has nothing to do with using <o:validateEqual>. You'd have exactly the same problem when not using it. You may however want to use OmniFaces FullAjaxExceptionHandler in order to get a real error page on an exception during an ajax request instead of complete lack of visual feedback.

Upvotes: 1

Related Questions