Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 导航到“时跳过验证”;“忘记密码”;页_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 导航到“时跳过验证”;“忘记密码”;页

Jsf 2 导航到“时跳过验证”;“忘记密码”;页,jsf-2,primefaces,Jsf 2,Primefaces,我正在编写一个基本的登录屏幕,其中包含用户名和密码的文本框、一个提交按钮和一个命令链接,用于重定向到页面以检索密码。我已经为两个文本字段设置了required=true,并且还设置了一条required消息。现在,如果我需要重定向到检索密码页面而不在文本框中输入任何文本,它将不允许我。请帮忙 <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitio

我正在编写一个基本的登录屏幕,其中包含用户名和密码的文本框、一个提交按钮和一个命令链接,用于重定向到页面以检索密码。我已经为两个文本字段设置了required=true,并且还设置了一条required消息。现在,如果我需要重定向到检索密码页面而不在文本框中输入任何文本,它将不允许我。请帮忙

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"        
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<ui:composition template="/template/Template.xhtml">
    <ui:define name="title">Login</ui:define>
    <ui:define name="pageContent">
        <h:form>
            <p:messages id="message1" closable="true"/>
            <p:panelGrid id="loginPanel" columns="2"
                style="margin-left: auto;margin-right: auto;margin-top: 10%;border-style:none">
                <h:outputLabel for="uName" value="User Name "></h:outputLabel>
                <p:inputText id="uName" value="#{loginBean.uName}" required="true"
                    requiredMessage="#{prop.userNameRequired}"></p:inputText>
                <h:outputLabel for="passwrd" value="Password "></h:outputLabel>
                <p:password id="passwrd" value="#{loginBean.passwrd}"
                    required="true" requiredMessage="#{prop.passwordRequired}"></p:password>
            </p:panelGrid>
            <p:commandButton id="login" value="Login"
                style="margin-left: 40%;margin-top: 2%"
                action="#{loginBean.authenticate}" ajax="false"></p:commandButton>
            <p:spacer></p:spacer>
            <p:commandLink id="forgotPass" value="Forgot User-Name/Password ?"
                style="margin-left: 4.5%;font-size:0.7em" action="ForgotPassword.xhtml?faces-redirect=true"></p:commandLink>                                                                  
        </h:form>
    </ui:define>
</ui:composition>
</h:body>
</html>

登录

默认情况下,任何命令组件都会提交和处理(并验证!)整个表单。您只需要执行页到页的导航。
是错误的工具。您应该改用

<h:link id="forgotPass" value="Forgot User-Name/Password ?"
    style="margin-left: 4.5%;font-size:0.7em" outcome="ForgotPassword.xhtml" />

另见:

BalusC,h:link和h:outputlink是否产生相同的结果?我检查了html,从互联网上可以找到,唯一的区别是h:outputlink可以与参数一起使用
采用JSF(隐式)导航案例结果。
采用URL。
可用于这两个系统。另请参见第一个“请参见”链接。我不会把这些链接放在我的答案上只是为了装饰。它们实际上指向一些更深入的背景信息和/或有用的附加信息。