Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @PostConstruct not working in @FacesValidator
  2. @ManagedProperty(value = "#{jndiServiceLocatorBean}")
  3. private final JndiServiceLocatorBean jndiServiceLocatorBean = null;
  4.        
  5. private UserBeanRemote userBeanRemote = null;
  6.  
  7. @PostConstruct
  8. public void postConstruct()
  9. {
  10.     this.userBeanRemote = (UserBeanRemote) this.jndiServiceLocatorBean.getRemoteBean(UserBeanRemote.class);
  11. }
  12.        
  13. @FacesValidator("fooValidator")
  14. public class FooValidator implements Validator {
  15.  
  16.     private UserBeanRemote userBeanRemote;
  17.  
  18.     public FooValidator() {
  19.         FacesContext context = FacesContext.getCurrentInstance();
  20.         JndiServiceLocatorBean jndiServiceLocatorBean = context.getApplication().evaluateExpressionGet(context, "#{jndiServiceLocatorBean}", JndiServiceLocatorBean.class);
  21.         this.userBeanRemote = (UserBeanRemote) jndiServiceLocatorBean.getRemoteBean(UserBeanRemote.class);
  22.     }
  23.  
  24.     // ...
  25. }