我正在阅读JBoss中的这个示例,其中使用@RequestScopedbean备份JSF page来传递用户凭据信息,然后将其保存在@sessionScoped bean.以下是JBoss文档的示例.
@Named @RequestScoped
public class Credentials {
private String username;
private String password;
@NotNull @Length(min=3, max=25)
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
@NotNull @Length(min=6, max=20)
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
}
Run Code Online (Sandbox Code Playgroud)
JSF表格:
<h:form>
<h:panelGrid columns="2" rendered="#{!login.loggedIn}">
<f:validateBean>
<h:outputLabel for="username">Username:</h:outputLabel>
<h:inputText id="username" value="#{credentials.username}"/>
<h:outputLabel for="password">Password:</h:outputLabel>
<h:inputSecret id="password" …Run Code Online (Sandbox Code Playgroud)