I have the following html file:
<h:body>
<h:form id="loginForm">
<p:growl id="msg" showDetail="true" life="3000" />
<p:panel header="Login" style="width: 360px;">
<h:panelGrid id="loginPanel" columns="2">
<h:outputText value="Username" />
<p:inputText id="username" value="#{loginBean.uname}" ></p:inputText>
<p:spacer></p:spacer>
<p:message for="username" ></p:message>
<h:outputText value="Password" />
<p:password id="password" value="#{loginBean.password}" feedback="false"></p:password>
<p:spacer></p:spacer>
<p:message for="password"></p:message>
<p:spacer></p:spacer>
<p:commandButton action="#{loginBean.loginPro}" value="Login" update="loginForm" ajax="true"></p:commandButton>
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
And the LoginBean is as follow:
@ManagedBean(name = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {
private static final long serialVersionUID = 1L;
private String uname;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String loginPro() {
boolean result = false;
try {
result = UserDAO.login(uname, password);
} catch (SQLException e) {
e.printStackTrace();
}
if (result) {
return "home";
} else {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_WARN,
"Invalid Login!",
"Please Try Again!"));
return "login";
}
}
I keep on receiving the following message eventhough loginPro method exists on LoginBean:
javax.servlet.ServletException: /index.xhtml: Property 'loginPro' not found on type beans.LoginBean javax.faces.webapp.FacesServlet.service(FacesServlet.java:659) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Any opinions?
try loginBean.loginPro()
with loginBean.loginPro u said there is a property variable with get/set