【问题标题】:Primefaces 6.0 xhtml page showing blank on redirect from another pagePrimefaces 6.0 xhtml页面在从另一个页面重定向时显示空白
【发布时间】:2016-09-26 20:55:13
【问题描述】:

使用 Primefaces 6.0/jsf 2.2.6。

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

所以第一个安全页面有:

<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,则页面加载正常。但是,如果我先转到另一个页面,然后从那里再次单击上面页面的菜单项,它会加载一个空白页面。如果我重新单击菜单项,页面会再次重新呈现正常。

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

【问题讨论】:

  • 嗨,欢迎来到 stackoverflow。请创建一个minimal reproducible example
  • 菜单项是动态构建的,太复杂了
  • 抱歉,但如果您无法创建minimal reproducible example(重现问题需要动态菜单吗?不能直接省略吗?)我怀疑有人能帮助您。 javascript是例如我认为肯定不相关

标签: primefaces jsf-2


【解决方案1】:

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

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

    &lt;ui:include src="/path/to/unsecure/eacCalculator.xhtml" /&gt;

【讨论】:

    【解决方案2】:

    好的,经过多次调试,我实际上发现了问题。 “使用哪个模板”被延迟到创建 bean 的事实导致 xhtml 中的 CustomMenu 仅在 Bean 实例化后触发。长话短说,它使用之前的屏幕设置导致 css 将数据向右滑动(这使得它在屏幕上变为空白)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-30
      • 1970-01-01
      • 2015-08-14
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-24
      • 1970-01-01
      相关资源
      最近更新 更多