相关疑难解决方法(0)

如何在运行时向@SessionScoped bean提供@RequestScoped bean实例?

我正在阅读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)

jsf ejb java-ee cdi managed-bean

7
推荐指数
1
解决办法
4190
查看次数

标签 统计

cdi ×1

ejb ×1

java-ee ×1

jsf ×1

managed-bean ×1