Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.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
Javascript 转发渲染时,JS不包含在.xhtml中_Javascript_Java_Jsf 2_Primefaces_Jsf 2.2 - Fatal编程技术网

Javascript 转发渲染时,JS不包含在.xhtml中

Javascript 转发渲染时,JS不包含在.xhtml中,javascript,java,jsf-2,primefaces,jsf-2.2,Javascript,Java,Jsf 2,Primefaces,Jsf 2.2,我正在开发一个Primefaces/JSF应用程序 在bean中,我使用以下脚本将呈现转发到另一个页面,而不是对应于bean的页面: FacesContext context = FacesContext.getCurrentInstance(); context.getApplication().getNavigationHandler().handleNavigation(context, null, "other-page.xhtml"); 在other page.xhtml中

我正在开发一个Primefaces/JSF应用程序

在bean中,我使用以下脚本将呈现转发到另一个页面,而不是对应于bean的页面:

 FacesContext context = FacesContext.getCurrentInstance();
    context.getApplication().getNavigationHandler().handleNavigation(context, null, "other-page.xhtml");
other page.xhtml
中,某些JS文件将不包括在内,从而影响页面的呈现

奇怪的是,如果我直接通过浏览器指向
other page.xhtml
,页面就会以正确的方式呈现。 为什么? 怎么可能呢

为什么手动导航会导致此问题?我该如何解决

使用
.dispatch
.redirect
不会出现问题,但由于其他原因,我无法同时使用这两种方法

这是页面代码:

    <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Challenge</title>
        <h:outputScript library="primefaces" name="jquery/jquery.js" />
    </h:head>
    <h:body>
        <h:form id="loginForm">


            <p:growl id="msg" showDetail="true" life="3000" />
            <p:panel header="CHALLENGE!!" style="width: 360px;">

                <h:panelGrid id="loginPanel" columns="2">

                    <h:outputText value="Username" />

                    <p:inputText id="username" value="#{challengeBean.username}" ></p:inputText>

                    <p:spacer></p:spacer>

                    <p:message for="username" ></p:message>

                    <h:outputText value="Password" />

                    <p:password id="password" value="#{challengeBean.password}"  feedback="false"></p:password>

                    <p:spacer></p:spacer>

                    <p:message for="password"></p:message>

                    <p:spacer></p:spacer>

                    <p:commandButton action="#{challengeBean.submit}" value="submit" update="submit" ajax="false"></p:commandButton>

                </h:panelGrid>

            </p:panel>

        </h:form>

    </h:body> 

</html>

挑战

请注意某些字符(如“”)在jsp/jsf中无效。这发生在我做比较的时候。尝试将javascript放入另一个文件并导入。我正在使用标记将所有导入委派给JSF/Primefaces,请参阅源代码的编辑答案。@BalusC您能帮我吗?有什么办法可以解决这个问题吗?我知道你是JSF中最聪明的人之一。ThxBe注意到某些字符(如“”)在jsp/jsf中无效。这发生在我做比较的时候。尝试将javascript放入另一个文件并导入。我正在使用标记将所有导入委派给JSF/Primefaces,请参阅源代码的编辑答案。@BalusC您能帮我吗?有什么办法可以解决这个问题吗?我知道你是JSF中最聪明的人之一。谢谢