JSF 2.0:如何设置验证错误的顺序 [英] JSF 2.0 : How to set order of validation error

查看:123
本文介绍了JSF 2.0:如何设置验证错误的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Jsf 2与Hibernate Validator一起使用.效果很好,但是我不知道如何设置所产生错误的顺序.

I am using Jsf 2 with Hibernate Validator. It works fine, but I don't know how I can set the order of the generated errors.

例如:

我的托管豆

public class UserPresentation {

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

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

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

In the frontend the passwordNullError appears before the emailNullerror in the generated ul-Tag. How can I change that?

推荐答案

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

You could bind the message labels to your inputs, using the for attribute. The validation messages will appear right behind the according inputs.

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

这篇关于JSF 2.0:如何设置验证错误的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆