Primefaces 6.0 xhtml页面显示从另一页重定向的空白

时间:2016-09-26 20:55:14

标签: primefaces jsf-2

使用Primefaces 6.0 / jsf 2.2.6。

我有一个页面(安全),其中包含另一个页面(不安全,有2个不安全页面的入口点,因此这个设置)由bean支持,它使用模板,该模板在运行时确定,即:< / p>

所以第一个安全页面有:

<h:body>
        <ui:include src="../unsecure/eacCalculator.xhtml" />
</h:body>

第二页:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:pe="http://primefaces.org/ui/extensions"
  xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
    <script type="text/javascript">
        $(document).on("keypress", ":input:not(text,textarea)", function (event) {
            if (event.keyCode == 13) {
                event.preventDefault();
            }
        });

    </script>
</h:head>
<ui:composition template="#{eacCalculatorBean.template}" >
    <f:event listener="#{eacCalculatorBean.getScreenStartupData()}" type="preRenderComponent" />
    <ui:define name="page-content">



.......

如果我在从动态构建的菜单项登录后直接点击页面的URL,则页面加载正常。但是,如果我先转到另一个页面然后从那里再次单击上面的菜单项,则会加载一个空白页面。如果我重新点击菜单项,页面将再次重新呈现。

在加载另一个页面后没有第一次加载会有什么可能的原因?

2 个答案:

答案 0 :(得分:0)

您使用包含文件的相对路径。如果您的第二页位于登录后页面的不同路径中,则可能无法解析文件位置。

  • 如果无法解析文件位置,请查看AS日志文件
  • 尝试模板内的绝对路径以排除此问题

    <ui:include src="/path/to/unsecure/eacCalculator.xhtml" />

答案 1 :(得分:0)

经过多次调试后我确实找到了问题。 &#34;使用哪个模板&#34;延迟直到创建bean导致xhtml中的CustomMenu仅在Bean实例化后触发。长话短说,然后使用之前的屏幕设置导致css向右滑动数据(这使得它在屏幕上显示为空白)。