if(null!=salary)
infor.setSalary(Integer.parseInt(salary));
infor.setBirthday(birthday);
int violationSize = 0;
ValidatorFactory vf = null;
Validator validator = null;
if (injectedValidatorFactory == null) {
message += "<b>Unable to ValidatorFactory injected as @Resource<br>";
violationSize += 1;
}
if (injectedValidator == null) {
message += "<b>Unable to Validator injected as @Resource<br>";
violationSize += 1;
}
// obtain the validator factory and validator instance from JNDI
try {
InitialContext ctx = new InitialContext();
vf = (ValidatorFactory)ctx.lookup("java:comp/ValidatorFactory");
validator = (Validator)ctx.lookup("java:comp/Validator");
Validator validator2 = (Validator)ctx.lookup("java:comp/Validator");
if (validator == validator2) {
message += "<b>JNDI Validator is a singleton<br>";
violationSize += 1;
}
} catch (NamingException e) {
// log this as a violation
message += "<b>Unable to obtain validator from JNDI:</b>" + e.getMessage() + "<br>";
violationSize += 1;
// this is an error condition, but just mark the error and
// create validators directly
vf = Validation.buildDefaultValidatorFactory();
validator = (Validator)vf.getValidator();
}
Object contextValidator = getServletContext().getAttribute("javax.faces.validator.beanValidator.ValidatorFactory");
if (contextValidator == null || !(contextValidator instanceof ValidatorFactory)) {
message += "<b>Unable to obtain validator from ServletContext: " + contextValidator + "</b><br>";