public class LoginBean extends Object implements Serializable
Uses the annotations ManagedBean
and RequestScoped
.
It appears that I can't use the implicit objects for JSF expression language (param, request, response, etc.) in the ManagedBean annotations.
Modifier and Type | Field and Description |
---|---|
private String |
password
User login password.
|
private SessionProperties |
sessionBean
I believe that the ManagedProperty annotation in
this method will cause the sessionProperties
bean to be created at the same time as the
loginBean.
|
private String |
userName
User name.
|
Constructor and Description |
---|
LoginBean()
This constructor reads the HTTP request parameter name and places
it in the user name field of the form.
|
Modifier and Type | Method and Description |
---|---|
String |
authorized()
Determines whether the combination of user name and user password represents
a valid user.
|
String |
getList()
Diagnostic routine listing session, application, and
request attributes.
|
String |
getPassword() |
SessionProperties |
getSessionBean() |
String |
getUserName() |
void |
setPassword(String value) |
void |
setSessionBean(SessionProperties value) |
void |
setUserName(String value) |
private String userName
The annotation ManagedProperty
apparently controls actions by the JSF
handler with regard to variables.
private SessionProperties sessionBean
The ManagedProperty annotation appears to work when referencing other managed beans but not when referencing implicit objects.
public LoginBean()
I had previously tried using #{param} in the ManagedBean annotation for a property, but it didn't seem to work. Some messages on the web indicated that it worked, but it may be implementation dependent.
The constructor will set the userName property to the value of the "name" parameter if the parameter is present.
FacesContext
,
ExternalContext
public String getUserName()
public void setUserName(String value)
public String getPassword()
public void setPassword(String value)
public String authorized()
In this case, the method accepts any login attempt using "password" for the password. In a real application, a more complicated algorithm would be used.
public String getList()
FacesContext
,
ExternalContext
public SessionProperties getSessionBean()
public void setSessionBean(SessionProperties value)