我在jsf inputText中遇到了奇怪的问题。在浏览器上,它在输入框中显示了管理bean名称和变量名称(即#{loginModel.userName})。以下是我的jsf页面代码
<body>
<f:view>
<h:form>
<h:outputLabel value="Username"></h:outputLabel>
<h:inputText value="#{loginModel.userName}"></h:inputText>
<h:outputLabel value="Password"></h:outputLabel>
<h:inputSecret value="#{loginModel.password}"></h:inputSecret>
<h:commandButton value="Submit" action="#{loginModel.process}" ></h:commandButton>
</h:form>
</f:view>
</body>
我的管理bean代码是
public class LoginModel {
private String userName;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String process(){
System.out.println("Logged in user id is "+this.getUserName()+" and password to access is "+this.getPassword());
return "Submit";
}
}
和我的faces-config.xml文件
<managed-bean>
<managed-bean-name>loginModel</managed-bean-name>
<managed-bean-class>net.varun.dto.LoginModel</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
以下是我在浏览器上的输出以及当我点击提交按钮
时我变为空答案 0 :(得分:1)
尝试以下代码:
更改你的h:commandButton for primefaces进程,partialSubmit
和ajax
<body>
<f:view>
<h:form>
<h:outputLabel value="Username"></h:outputLabel>
<h:inputText value="#{loginModel.userName}"></h:inputText>
<h:outputLabel value="Password"></h:outputLabel>
<h:inputSecret value="#{loginModel.password}"></h:inputSecret>
<p:commandButton value="Submit" action="#{loginModel.process}" process="@form" partialSubmit="true" ajax="true" />
</h:form>
</f:view>
</body>
因此,您可以在流程方法中放置断点以查看更新值。