Hello,

i wrote an own jsf validator(which performs a database lookup) a time ago 
and want to reuse it for my current seam application


The thing is, in my Validator class i need database access and the 
EntityManager will be null (i think the reason is the ValidatorClass will be 
instantiated by jsf , out of the seam context)


JSP

  | <f:validator validatorId="nickNameValidator"/>
  | 

JAVA


  | @Name("NickNameValidator")
  | @Interceptors(SeamInterceptor.class)
  | public class NickNameValidator implements Validator {
  |     
  |     //@PersistenceContext
  |     //@In(value="dataSource")
  |     @PersistenceContext
  |     private EntityManager entityManager;
  |     //private IDataSource dataSource;
  | 
  |     
  |     public void validate(FacesContext fc, UIComponent uic, Object o) {      
        
  |             String nickName = (String)o;
  |             
  |             System.out.println("entityManager: "+entityManager);
  |             
  |             
  |             ValidatorException validatorException = checkNickName(fc, 
nickName);
  |         if (validatorException != null) {
  |             ((UIInput)uic).setValid(false);
  |             throw validatorException;
  |         }
  |     }
  | }
  | 

I know i can perform validation via the Hibernate Framework , but id like to 
reuse my old cold and i also did not found any examples how to do "database 
based validation" with the annotation syntax.


Thank u very much,

Holger


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953587#3953587

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953587

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to