Hello all... does anyone know if it's possible to use dependency injection inside JSF validators? My code is as follows:
package com.ibm.wasce.customerLocator.web.jsf; import javax.ejb.EJB; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.component.UIComponent; import com.ibm.wasce.customerLocator.ejb.interfaces.CustomerBeanLocal; public class CustomerNumberValidator implements Validator { @EJB(name="CustomerBeanLocal") CustomerBeanLocal customerSessionBean; public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { System.out.println(customerSessionBean); if(customerSessionBean.findCustomerByCustomerNumber((String)value) != null) { FacesMessage message = MessageGenerator.getCustomerNumberAlreadyExistsMessage(); throw new ValidatorException(message); } } } The problem is that customerSessionBean is coming up as null. Of course, this behavior makes sense because the validator is not a managed bean. But is there a way to treat it as if it was? -- View this message in context: http://www.nabble.com/Dependency-Injection-in-Validators-tp16397217p16397217.html Sent from the MyFaces - Users mailing list archive at Nabble.com.