1

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?

4

1 に答える 1

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

これは基本的に、空の値の式に対して「設定」操作 (setter メソッドの呼び出し) を実行できないことを示しています。

value属性を完全に (少なくとも「確認」フィールドから)削除するか、value="#{bean.password}"(少なくとも最初のフィールドに対して) のような有効な値式を指定します。だから基本的に:

<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" />

これは使用とは関係ありません<o:validateEqual>。使用しない場合は、まったく同じ問題が発生します。FullAjaxExceptionHandlerただし、視覚的なフィードバックが完全に欠けているのではなく、ajax リクエスト中に例外で実際のエラー ページを取得するために、OmniFaces を使用することをお勧めします。

于 2012-11-13T12:33:39.420 に答える