I have this code:
<h:form id="login">
<p:messages id="messages" globalOnly="true"/>
<h:panelGrid columns="3" cellpadding="5" style="margin: 0 auto;">
<p:outputLabel for="username" value="Username"/>
<p:inputText id="username" value="#{loginManager.username}"/>
<p:message for="username"/>
<p:outputLabel for="password" value="Password"/>
<p:inputText type="password" id="password" value="#{loginManager.password}"/>
<p:message for="password"/>
<p:commandButton id="submit" update="@form" value="Login" action="#{loginManager.submit}"/>
</h:panelGrid>
</h:form>
and in the loginManager class which looks like this,
@Named
@RequestScoped
public class LoginManager {
@NotEmpty
@Size(min = 4, message = "Please provide a valid username")
private String username;
@NotEmpty
@Size(min = 5, message = "Please provide a valid password")
private String password;
@Inject
private SecurityContext securityContext;
@Inject
private ExternalContext externalContext;
@Inject
private FacesContext facesContext;
public void submit() throws IOException {
System.out.println("username is " + username);
System.out.println("password is " + password);
// do something
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
but when I click the login button, the sysout prints the values as null even though there were values I inputted before submit button was clicked. What is wrong with what I have set up? I am getting frustrated