JSF ui:包括未正确呈现 [英] JSF ui:include not being rendered properly

查看:104
本文介绍了JSF ui:包括未正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 JSF 2.1.8 实现一个Web应用程序,我对 ui:include 标记有疑问。我有这个代码

I'm implementing a web application using JSF 2.1.8 and I have a problem with the ui:include tag. I have this code

<h:panelGroup id="panelContenido">

        <ui:fragment rendered="#{!empty navigationManagerSystem._Navegable}">
            <ui:include src="#{navigationManagerSystem._Navegable._IncludePath}" />

        </ui:fragment>
        <ui:fragment rendered="#{empty navigationManagerSystem._Navegable}">
            <ui:include src="/system/navigation/error.xhtml" />
        </ui:fragment>
    </h:panelGroup>

navigationManagerSystem bean是JSF会话管理的,当这段代码是首先渲染,它应该显示包含路径内容。如果我按照< ui:include /system/home/index.xhtml/> 这样的常量执行此操作,但是如果我将其放入变量,即使我已经看到变量在屏幕打印之前保持该值。我不知道它是否与持有/system/home/index.xhtml页面的bean有关,这是查看Scoped

The navigationManagerSystem bean is JSF session managed and when this piece of code is firstly rendered, it is supposed to show the include path content. This include works if I do it in a constant like that <ui:include /system/home/index.xhtml" /> but not if I put it in the variable, even I have seen the variable is holding that value before the screen prints. I don't know if it can be related with the bean that holds /system/home/index.xhtml page, which is View Scoped.

无论如何,如果我在页面渲染后立即刷新页面,则正确包含xthml。顺便说一下,我已经简化了要包含的页面为了没有任何jstl标签,因为我知道它们可能会导致View Scope出现问题。

Anyway, if I do a page refresh just after page rendering, the xthml is properly included. By the way, I have simplified the page to be included in order to not have any jstl tags, because I know they can cause problems with View Scope.

有什么想法吗?

推荐答案

关于问题的原因,< ui:include> 在视图构建期间运行(恢复查看阶段)不是在你期望的视图渲染时间(渲染响应阶段)。所以如果包含路径在例如调用动作阶段或甚至渲染响应阶段期间发生变化,除非它完全重建,否则它不会反映在视图中。

As to the cause of the problem, the <ui:include> runs during view build time (restore view phase) not during view render time (render response phase) as you seem to expect. So if the include path changes during for example invoke action phase or even render response phase, then it won't be reflected in the view unless it's completely rebuilt.

目前,您最好的选择是使用多个静态< ui:包含> 标记,这些标记在视图渲染时间内有条件地呈现。没错,最终会出现一个不必要的大型组件树。对于这个问题,仍然没有圣杯解决方案。问题清楚地被理解,但考虑到JSF / Facelets生命周期,解决方案很难。我也为OmniFaces做了一些实验,但是最简单的尝试在MyFaces中很难在Mojarra工作(在某种程度上)。

Currently, your best bet is to use multiple static <ui:include> tags which are each conditionally rendered during view render time. True, this ends up with an unnecessarily large component tree. There is still no "holy grail" solution for this problem. The problem is clearly understood, but the solution is hard given the JSF/Facelets lifecycle. I have for OmniFaces done some experiments on that as well, however the simplest attempt fails hard in MyFaces while it works (to certain degree) in Mojarra.

  • How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)
  • Dynamic ajax navigation with <ui:include>

这篇关于JSF ui:包括未正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆