我在 jsf 中编写一个注册表格:
在 *.xhtml 文件中:
<h:outputLabel class="Float" for="password" value="Passwort"/>
<h:inputText id="password" rendered="true" value="#{Register.password}" label="Passwort">
<f:validateLength minimum="3" maximum="8"/>
</h:inputText>
</fieldset>
</h:form>
在豆子里:
public String getPassword() {
return password;
}
public void setPassword(String pwd) {
this.password = pwd;
}
我设置了一个断点并注意到我的设置器没有到达?
为什么?
++++1.更新++++++
注册.java:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
@ManagedBean(name="Register")
@SessionScoped
public class Register implements Serializable{
private String password = "Fill in!";
/** Creates a new instance of Customer */
public Register() {
//null
}
public String getPassword() {
return password;
}
public void setPassword(String pwd) {
this.password = pwd;
}
++++2.更新++++++
<div id="buttons">
<h:commandButton id="enter" accesskey="r" value="Registrieren" action="#{Register.registerPlayer()}" immediate="true"/>
</div>
++++3.Update++++++ 我的表单代码:
<!-- Login-->
<h:form>
<h3><span xml:lang="en">Login</span> Daten </h3>
<div class="formblock">
<fieldset>
<div>
<h:outputLabel class="Float" for="username" value="Username"/>
<h:inputText id="username" rendered="true" value="#{Register.username}" label="Username">
</h:inputText>
</div>
<div>
<h:outputLabel class="Float" for="password" value="Passwort"/>
<h:inputSecret id="password" rendered="true" value="#{Register.password}" label="Passwort">
</h:inputSecret>
</div>
</fieldset>
</div>
<div id="buttons">
<h:commandButton id="enter" accesskey="r" value="Registrieren" action="#{Register.registerPlayer()}" immediate="true"/>
<!-- <h:outputText value="#{msg.wrongpwd}" rendered="#{loginCtrl.loginfailed}" style="color: red"/>
<h:messages style="color: red"/> -->
</div>
</h:form>