Seam supports this kind of injection via @in and @out annotations http://www.javabeat.net/jboss-seam/2007/06/jboss-seam-introduction/
Another way would be to integrate Spring + JSF. Yet another way would be to manage business layer with Spring and then you an instance of a bean which implements ApplicationContextAware to get you any spring bean reference to any other bean not managed by Spring. ~madhav On Mon, Mar 31, 2008 at 1:42 PM, Cedric Hurst <[EMAIL PROTECTED]> wrote: > > 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. > > -- When I tell the truth, it is not for the sake of convincing those who do not know it, but for the sake of defending those that do