2012-06-21 37 views
2

我正在使用Jsf 2和Hibernate Validator。它工作正常,但我不知道如何設置生成的錯誤的順序。JSF 2.0:如何設置驗證錯誤的順序

有關示例:

我管Bean

public class UserPresentation { 

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

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

在passwordNullError的emailNullerror之前出現在所生成的UL-標籤前端。我該如何改變它?

回答

1

您可以使用for屬性將郵件標籤綁定到輸入。驗證消息將顯示在相應輸入的後面。

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

我的設計需要一個消息組件。還有其他解決方案嗎? –