I have a JSF Validator that I create that has properties that I would like to load from a ResourceBundle. However, I'm not quite sure how this works, as it does not load properly. Any ideas on how I can make this work?
I tried using @PostContruct to do this, but I get the following error in Eclipse:
Access restriction: the PostConstruct type is not available due to the restriction on the required library / System / Library / Java / JavaVirtualMachines / 1.6.0.jdk / Contents / Classes / classes.jar
So I'm not too sure how this works best. An example of what I'm talking about below ...
Validator ...
@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 {
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
source share