JSF 2.0 Facelets標籤之ui:include

一.先上各種對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的指向。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章