我正在构建一个JSF验证器,其中有属性需要从ResourceBundle中加载。然而,我不太确定如何使用它,因为它并没有正确加载。你有什么想法可以让这个工作起来吗?
我尝试使用
“Access restriction: The type PostContruct is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar”
所以,我不太确定最好的解决方法是什么。下面是我所说的示例... 该验证器...
我尝试使用
@PostConstruct
来进行操作,但是在Eclipse中出现了以下错误:“Access restriction: The type PostContruct is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar”
所以,我不太确定最好的解决方法是什么。下面是我所说的示例... 该验证器...
@FacesValidator("usernameValidator")
public class UserNameValidator implements Validator {
@ManagedProperty(value="#{props_userNamePattern}")
private String userNamePattern;
@ManagedProperty(value="#{props_minUserNameLength}")
private int minUserNameLength;
@ManagedProperty(value="#{props_maxUserNameLength}")
private int maxUserNameLength;
public void validate(FacesContext context, UIComponent component, Object
value) throws ValidatorException {
//My validations here...
}
//Setters for the class properties
}
faces-config.xml
<resource-bundle>
<base-name>settings</base-name>
</resource-bundle>
settings.properties
props_userNamePattern = /^[a-z0-9_-]+$/
props_minUserNameLength = 3
props_maxUserNameLength = 30