10 Replies Latest reply on May 18, 2009 12:13 PM by Alexander Bell

    Injection problem

    Alexander Bell Newbie


      I tried the JSF example of chapter 2 (in a small different way).

      I've got a User WebBean which should be in the Request Context:

      public class User implements Serializable {
              private static final long serialVersionUID = 1L;
              private String name;
              private String password;

      I've got also an AuthenticationService which has got the session scope and inject the User with @Current

      public class AuthenticationServiceImpl implements AuthenticationService {
              private static final long serialVersionUID = 1L;
              private @Current User loginData;

      Finally I've got a simple xhtml page:

        Username <h:inputText value="#{credentials.name}" />
        Password <h:inputText value="#{credentials.password}" />
        <h:commandButton actionListener="#{authenticationService.login}" value="Login" />

      If I press the Login Button I get into the action login in authenticationService (so far so good). But in the authentication service I've got a new User so the name and the password properties are null.

      Afterwards I've use a debugger to see what happens:
      1. Call the setter for name and password for a User object
      2. Call the login action but with a different User object as in 1.

      So I suppose I've got two user object in two different scopes.
      In 1. dependent scope and in 2. Request scope.

      My environment: Tomcat6, JSF2.0 (Mojarra)

      Any ideas?