2 Replies Latest reply on May 22, 2010 11:01 PM by kem

    Outjected Component Null

    kem Newbie

      Hi


      I am testing Bijection with the following code. The Injection is OK, but @Out always outject null.


      Any idea what is wrong in this code. Many Thanks



      @Name("person")
      public class Person {
              private String firstName;
              private String lastName;
      
              public String getFirstName() {
                      return firstName;
              }
              public void setFirstName(String firstName) {
                      this.firstName = firstName;
              }
              public String getLastName() {
                      return lastName;
              }
              public void setLastName(String lastName) {
                      this.lastName = lastName;
              }
      }
      




      the following class rename the firstName and Outject Person.
      @In pesron is OK. But @Out person is always null.


      @Stateful
      @Name("rename")
      public class PersonRename implements Rename {
              @In @Out
              Person person;
      
              public String rename() {
                      String fn = person.getFirstName();
                      person.setFirstName("renamed-" + fn);
                      return "/confirm.xhtml";
              }
              
              public Person getPerson() {
                      return person;
              }
              
              public void setPerson(Person person) {
                      this.person = person;
              }
                      @Remove
              public void destroy(){};
      }
      



      @Out person is injected in manager. But injected person is always Null.


      @AutoCreate... for person is not useful, as the firstName and lastName are set from the view.



      @Stateful
      @Name("manager")
      public class PersonManager implements Manager {
              @In StatusMessages statusMessages;
      
              @In
              Person person;
      
              public void confirm() {
                      statusMessages.add("Confirm New firstName: " + person.getFirstName());
              }
      
              public Person getPerson() {
                      return person;
              }
      
              public void setPerson(Person person) {
                      this.person = person;
              }
      
              @Remove
              public void destroy(){};
      
      }
      








        • 1. Re: Outjected Component Null
          shravan kodam Newbie

          Can you please try something like this - by giving the parameter names
          '@In(required = true/false)
          @Out(required = true/false, scope = ScopeType.SESSION)
          private User user;'

          • 2. Re: Outjected Component Null
            kem Newbie

            Thanks Shravan,
            I think your suggestion is in the right direction.


            I actually found the explanation of the problem in one of Seam books I have. I have read in the past that the default scope in Seam is conversation. So I didn't specified scope  for the components.
            However, I just found that the default conversation scope is just a temporary conversation that ends once the first response is rendered. Therefor, all outject object once the conversation ends, are null. I have to specify the Conversation scope.