1 Reply Latest reply on Apr 8, 2008 12:37 PM by pmuir

    Disinject question - non @In attribute is set to null?

    fsat.f_satyaputra.yahoo.co.uk

      Hi All,


      I have another question on how disinject works on Seam 2.0.1 GA using facelet.


      If I have an attribute that is not annotated with @In, will it be disinjected?


      It seems I have an instance variable which is disinjected even though it's not annotated with @In. Is this an expected behaviour?


      I have the following link:


      <li><s:link id="sftest" view="/sftest/start.xhtml" action="#{formTestPageBean.prepareSave()}" value="Start Sub Form Test"/></li>
      



      Which fires the following method of the page bean:


      @Name("formTestPageBean")
      public class FormTestPageBean {
              @In
              protected FormManager formManager;
              
              @Begin(join=true)
              @RaiseEvent("formgroup.initialize")
              public String prepareSave() {
                      this.formManager.initialize();          
                      return "prepareSave";
              }
              // snip...      
      }
      



      The event is observed by the following class:


      @Name("companyFormGroup")
      @Scope(ScopeType.CONVERSATION)
      public class CompanyFormGroup extends BaseFormGroup {
              private List<SubForm> completeSubFormList = new LinkedList<SubForm>();
              private Set<SubForm> displaySubForms = new TreeSet<SubForm>(new DisplaySubFormComparator());        
      
              @Override
              @RaiseEvent("companyFormGroup.initialize")
              public void register() {
                      this.initialize();
                      this.formManager.register(this);
              }
              
              public void addSubForm(SubForm subForm) {
                      this.completeSubFormList.add(subForm);          
                      this.displaySubForms.add(subForm);                      
                      System.out.println("" + this + ".addSubForm(" + subForm + ") - display size [" + this.displaySubForms.size() + "]");
              }
              
          // snip...
      }    
      



      which in turn it's observed by the following:


      @Name("businessPremiseSubForm")
      @Scope(ScopeType.CONVERSATION)
      public class BusinessPremiseSubForm extends BaseSubForm {
              @In
              protected CompanyFormGroup companyFormGroup;
              
              @Observer("companyFormGroup.initialize")
              public void register() {
                      this.companyFormGroup.addSubForm(this);
              }
      
              // snip...
              
      }
      



      The output when the link is clicked:


      com.juggle.seam.form.formgroup.base.CompanyFormGroup@964b4d.addSubForm(com.juggle.seam.form.subform.base.BusinessPremiseSubForm@94d605) - display size [1]
      



      On the I am on the facelet page, I have the following snippet:


              <c:forEach var="e" items="#{formManager.displayFormGroups}">
                      #{e.displaySubForms} <br/>
              </c:forEach>
          #{companyFormGroup.displaySubForms.size()}
      


         
      The code {e.displaySubForms} gives null, but calling {companyFormGroup.displaySubForms} gives me a collection with BusinessPremiseSubForm.


      I am not sure what's the difference between the two code above.


      Apologies for the long email, and thanks in advance for anyone who has spent time looking at this email.


      Regards,


      Felix