2011-09-23 62 views

回答

3

验证任何你在JSF需要的是使用MyFaces Extval的最佳方式的最佳途径。它支持交叉字段验证,这是验证密码的典型用例。有关详细信息,请参阅this blog

1

您可以使用RichFaces 4客户端!基于Bean验证的验证(JSR303)。

豆:

@Size(min = 5, max = 15) 
private String password1; 

@Size(min = 5, max = 15) 
private String password2; 

@AssertTrue(message = "Passwords don't match") 
public boolean checkPassword() { 
    return password1.equals(password1); 
} 

页:

<rich:graphValidator value="#{bean}" id="crossField"> 
    <h:inputText value="#{bean.password1}"/> 
    <h:inputText value="#{bean.password2}"/> 
    <rich:message for="crossField"/> 
</rich:graphValidator> 

参考here更多的例子。

+0

但我使用icefaces和一些纯jsf,所以我怎么能没有richFaces做到这一点? –

+0

IceFaces和RichFaces可以很好地协同工作,您还可以将RichFaces添加到您的应用程序中。我为您看到以下选项:1)RichFaces 2)seam-faces 3)解决方法,请参阅:http://stackoverflow.com/q/6282466/854386。 – Andrey