3 Replies Latest reply on Sep 6, 2007 5:15 AM by pmuir

    hibernate validator: how to access seam component

    amashtakov

      Hi everybody,

      There are two ejb-s:

      - Account (entity)

      Account {
      ...
      @AccountLogin
      public String getLogin() {...}
      ...
      }

      - AccountManager (session)

      @Name("accountManager")
      AccountManager {
      ...
      public Account findByLogin(String login) {...}
      ...
      }

      In order to check if account with the same login already exists or not, I
      developed a hibernate validator:

      @ValidatorClass(AccountLoginValidator.class)
      @Target(ElementType.METHOD)
      @Retention(RetentionPolicy.RUNTIME)
      @Documented
      public @interface AccountLogin {
      String message() default "the same login already exists";
      }

      I'm trying to inject "accountManager" component into AccountLoginValidator in order to perform check but with no
      success - instance variable is always null:

      @Name("accountLoginValidator")
      public class AccountLoginValidator
      implements Validator, PropertyConstraint {

      @In(create=true, value="accountManager")
      private AccountManagerLocal accountManager;

      ...
      }

      With jndi lookup everything works fine, but I'd like to use seam
      injection facilities to get this reference.

      In any way to do this ?


      PS:

      In page code bean I always get the reference to "accountManager"
      without any problem using the same @In anotation.