一.先上各种对ui:include的解释说明:
1.The UI Include tag is a server-side include tag for Facelets. It simply includes the document pointed to by the "src" attribute as part of the current JSF page. The included document should use a component or composition tag to trim unnecessary markup, or it may simply contain a fragment of XHTML or XML to be included.(From JSFToolBox.com)
ui:include标签服务器端的Facelets包含标签,它把src属性指示的页面的内容简单地包含到当前页面ui:include所在位置。被包含的内容应该由ui:composition或ui:component标包围着。
2.The ui:include tag is the Facelets equivalent of the jsp:include tag. It provides the ability to
include/insert markup into a Facelet view or composition that is contained in a separate
XHTML file.(From JavaServer Faces 2.0:The Complete Reference)
这个更没解释一样。
二.ui:include用法
1.被所有客户页面(client page)共用的内容放在模板页面(template page)中,被某些客户页面共用的内容放在单独文件中,然后用ui:include将其加载到需要的地方。
2.被包含页面
• 把内容放在ui:composition之内,注意命名空间。ui:composition之外的内容在加载时将被忽略。
• 放在单独文件里,最好放在另一个文件夹(如sinppets/、includes/)。
• 内容必须遵从XML语法格式。
• 被包含页面也可 以使用模板文件,但是模板文件中的最顶层标签是<ui:composition>而不是<html>,因为需要的是片段内容而不是html文件.
三.使用问题
1.使用ajax异步刷新似乎无法动态改变ui:include的指向。