Bean クラスで if ステートメントを使用してユーザーが投票できるかどうかを表示する投票アプリをセットアップしようとしていますが、この Unable to find matching navigation case with from-view-id '/home.xhtml'アクション「#{user.checkAge(user.age)}」の結果「無効なユーザー、再試行してください!!!」。私はまだJava Server Facesについてよく理解していません.configファイルをいじってエラーをグーグルで調べてみましたが、修正できません. 誰でも私を助けてください。
これが私のコードです:
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;
}
}