Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems with validation and getting data from EJB

 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I'm trying to write a custom validator as described here

The validator is intended for use with new users registering and he has to check whether the login given by user is still available. Therefore I need to connect with the data layer to execute a finder on users. Is there any simple way of doing that?

@PersistenceContext
private EntityManager em;

doesn't help since validator aint a bean.

Thanks in advance for any help,

Kind Regards,

karol
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going by the validator example that you pointed out, the Validator appears to be just some simple Java class. Instead of injecting the EntityManager, you can look up the EntityManager through JNDI lookup code, in your validator class. By default in JBoss, the EntityManager is not available in the JNDI. Go through this chapter ("Persistence unit JNDI Bindings" section) which explains how to make the EntityManager available in the JNDI tree, in JBoss.
 
Karol Oslowski
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for this answer. I'm getting the context throught jndi lookup and all is working fine!

Cheers,

k.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic