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表单中的自动单击功能_Jsf_Jsf 2 - Fatal编程技术网

需要JSF表单中的自动单击功能

需要JSF表单中的自动单击功能,jsf,jsf-2,Jsf,Jsf 2,加载下面的JSF页面后,我需要自动单击登录链接。请帮忙! 单击登录链接后,此表单将显示一个登录链接并打开一个新窗口。 如果我可以直接提交表格而不显示登录链接也可以 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http:/

加载下面的JSF页面后,我需要自动单击登录链接。请帮忙! 单击登录链接后,此表单将显示一个登录链接并打开一个新窗口。 如果我可以直接提交表格而不显示登录链接也可以

<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:c="http://java.sun.com/jstl/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich">
        <head>
                <title>MY System &#174;</title>
                <meta http-equiv="pragma" content="no-cache" />
                <meta http-equiv="cache-control" content="no-cache" />
                <meta http-equiv="expires" content="0" />
                <meta http-equiv="keywords" content="My System" />
                <link rel="stylesheet" type="text/css"
                        href="${facesContext.externalContext.requestContextPath}/style/source.css"></link>
                <script type="text/javascript"
                        src="${facesContext.externalContext.requestContextPath}/js/Utility.js"></script>
        </head>
        <body>
                <ui:include src="common/header.xhtml" />
                <div class="table"
                        style="position: absolute; top: 160px; width: 960px; text-align: center; float: center; margin-left: auto;">
                        <form id="initForm">
                                <span class="warning"> Welcome to MY System, please <a
                                        href=""
                                        onclick="newSourceWindow('${facesContext.externalContext.requestContextPath}/home.jsf');"
                                        style="color: blue; text-decoration: underline; cursor: pointer;">Login</a>
                                        to start. </span>
                        </form>
                        <rich:spacer height="40" />
                        <ui:include src="common/footer.xhtml" />
                </div>
        </body>
</html>
var spanEle = document.getElementById('welcomeLink');
spanEle.click()

我的系统®;
欢迎使用我的系统
开始。

给你的
span
提供Id
通过Javascript访问它,您可以用它做任何事情,在您的情况下,触发单击

<span id="welcomeLink">
...
</span>
var spanEle = document.getElementById('welcomeLink');
spanEle.click()