1 Reply Latest reply on Mar 31, 2008 12:22 PM by pmuir

    Null session-scoped component

    cristinacom

      Hello,


      I am using Facelets, and I am trying to access some Seam components in a tag-like class. I have this UIXtw class that I use like a tag. It is 'mapped' in brit.taglib.xml and that taglib is linked into web.xml as I learned from some tutorials online:


      @Name("UIXtw")
      @AutoCreate
      public class UIXtw extends UIOutput {
      
          @In
          private LocalXTextSessionWrapper xtw;
          
          @Override
          public void encodeBegin(FacesContext context) throws IOException {
              // XTextSessionWrapper xtw = (XTextSessionWrapper) Contexts.getSessionContext().get("xtw");
              log.info("xtw= #0", xtw);
              log.info("xtw.activeLanguage= #0", xtw.getActiveLanguage());
              ...
          }
      
          @Override
          public void encodeEnd(FacesContext context) throws IOException {
          }
      }
      



      XTextSessionWrapper.java:


      @Stateful
      @Name("xtw")
      @Scope(ScopeType.SESSION)
      @AutoCreate
      public class XTextSessionWrapper implements LocalXTextSessionWrapper {
      ...
          @In(required = false, create = true)
          @Out(required = false)
          private XLanguage activeLanguage;
      
          public XLanguage getActiveLanguage() {
              if (activeLanguage == null) {
                  setActiveLanguage(xLanguageDAO.findXLanguageByIdentifier("ro"));
              }
              return activeLanguage;
          }
      
          public void setActiveLanguage(XLanguage activeLanguage) {
              this.activeLanguage = activeLanguage;
          }
      ...
      }
      



      Well, the problem is that when the encodeBegin() method is called, it cannot find the injected LocalXTextSessionWrapper and it reports it as null. As you can see from the commented line, I have also tried to get it from the session context manually with no success. I must mention that the same xtw injected in other components works fine.


      Could anyone please turn the lights on this problem? What am I missing? Why is the injected value null?


      Thank you in advance for any hint,
      Cristina.