users@glassfish.java.net

GF3.1 @Named annotation not working but @ManagedBean does

From: <forums_at_java.net>
Date: Fri, 11 Mar 2011 17:12:31 -0600 (CST)

When I run the code like the following that is part of an entire program,
consist of a Bean (the following code), a XHTML login page and another XHTML
welcome page after login submission, I received an error after login page
submisstion:

 

HTTP Status 500 with exception: javax.servlet.ServletException: /login.xhtml
@16,46 value="#{user.name}": Target Unreachable, identifier 'user' resolved
to null.

 

However after I changed @Name("user") to @ManagedBean(name="user"), the
program runs without error.  Is this due to a bug in GF3.1?

Cheers, lchong2

 

// UserBean
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
@Named("user")  //or @ManagedBean(name="user")
@SessionScoped
public class UserBean implements Serializable {
    private String name;
    private String password;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
   
}


--
[Message sent by forum member 'lchong2']
View Post: http://forums.java.net/node/780709