简单的导航 Navigation
<%@ taglib uri= <%@page contentType="text/html;charset=Big5"%> <html> <head> <title>第一个JSF程序</title> </head> <body> <f:view> <h:form> <h3>请输入您的名称</h3> <h:outputText value="#{user.errMessage}"/><p> 名称: <h:inputText value="#{user.name}"/><p> 密码: <h:inputSecret value="#{user.password}"/><p> <h:commandButton value="送出" action="#{user.verify}"/> </h:form> </f:view> </body> </html>
当要根据verify运行结果来决定页面流程时,action属性中使用 JSF Expression Language "#{user.verify}",如此JSF就知道必须根据verify传回的结果来导航页面。
<h:outputText>可以取出指定的Bean之属性值,当使用者因验证错误而被送回原页面时,这个错误讯息就可以显示在页面上。