I'm trying to set up a voting app that will display whether the user is able to vote or not using an if statement in my bean class but this Unable to find matching navigation case with from-view-id '/home.xhtml' for action '#{user.checkAge(user.age)}' with outcome 'Invalid User, Please Try Again!!!'. Im not very understanding of Java Server Faces yet and ive tried messing around with the config files and googling the error but i cant fix it. Can anyone help me please.
Here is my code:
Home.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
<title>Results Page</title>
</head>
<body>
<h:form>
Name: <h:outputText id="outTxt" value="#{user.name}"/><br></br>
Age: <h:outputText id="outTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check" action="#{user.checkAge(user.age)}"/>
</h:form>
</body>
</html>
index.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Home Page</title>
</h:head>
<h:body>
<h:body>
<h:form>
Name: <h:inputText id="inTxt" value="#{user.name}"/><br></br>
Age: <h:inputText id="inTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check" action="home"/>
</h:form>
</h:body>
</h:body>
</html>
User.java
package MyPackage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class User
{
private String name;
private int age;
private String msg;
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String checkAge(int checkAgeVoter)
{
if(checkAgeVoter >= 18)
{
msg = "Valid User, Access Granted!!!";
}
else
{
msg = "Invalid User, Please Try Again!!!";
}
return msg;
}
}