【问题标题】:JSF 2.0 : How to set order of validation errorJSF 2.0:如何设置验证错误的顺序
【发布时间】:2012-06-21 13:45:28
【问题描述】:

我正在使用带有 Hibernate Validator 的 Jsf 2。它工作正常,但我不知道如何设置生成错误的顺序。

举个例子:

我的托管豆

public class UserPresentation {

@NotNull(message = "EmailNullError")
@Email(message="EmailNotValidError")
String email;

@NotNull(message="passwordNullError")
String password;
//getter,setter...
} 

在前端,passwordNullError 出现在生成的 ul-Tag 中的 emailNullerror 之前。我该如何改变呢?

【问题讨论】:

    标签: jsf hibernate-validator


    【解决方案1】:

    您可以使用for 属性将消息标签绑定到您的输入。验证消息将出现在相应的输入后面。

    <h:inputText value="#{myBean.email}" id="email" />
    <h:message for="email" />           
    <h:inputSecret value="#{myBean.password}" id="password" />
    <h:message for="password" />
    

    【讨论】:

    • 我的设计需要一个消息组件。有没有其他解决方案?
    猜你喜欢
    • 1970-01-01
    • 2011-06-29
    • 2014-04-11
    • 1970-01-01
    • 2012-01-30
    • 2012-02-23
    • 2011-04-16
    • 2012-07-14
    • 2015-12-22
    相关资源
    最近更新 更多