我想創建由「標題」和「內容」組成的頁面。我創建common.xhtml春季Web流和JSF模板
<ui:insert name="header">
<ui:include src="commonHeader.xhtml" />
</ui:insert>
<ui:insert name="content">
<ui:include src="commonContent.xhtml" />
</ui:insert>
然後,我創建兩個頁面(create_user_page.xhtml和search_page.xhtml),它必須具有相同的 「頭」 和而不同 「內容」
<ui:composition template="common.xhtml">
<ui:define name="content">
<h1>Content for creating...</h1>
<ui:include src="create.xhtml"/>
</ui:define>
</ui:composition>
和
<ui:composition template="common.xhtml">
<ui:define name="content">
<h1>Content searching...</h1>
<ui:include src="search.xhtml"/>
</ui:define>
</ui:composition>
在我web_flow.xml我有
<view-state id="start_page" view="administrator/main_page.xhtml">
<transition on="create_user" to="create_user_page" />
<transition on="find_user" to="search_page" />
<transition on="back" to="back" />
</view-state>
<view-state id="create_user_page" view="administrator/create_user_page.xhtml">
<transition on="create_user" to="create_user_page" />
<transition on="find_user" to="search_page" />
</view-state>
<view-state id="search_page" view="administrator/search_page.xhtml">
<transition on="create_user" to="create_user_page" />
<transition on="find_user" to="search_page" />
</view-state>
在main_page.xhtml我有兩個操作「create_user」和「find_user」(在「header」中),這導致頁面 create_user_page.xhtml和search_page.xhtml。他們有類似的「標題」,並在「內容」上有所不同。所有這些都很好,但我有一些問題。
1)每次進入create_user_page.xhtml或search_page.xhtml時,似乎都會重新呈現「標題」,或者我錯了?是否有可能「標題」將保持不重新呈現和更改將只爲「內容」。
2)在我的網站流量XML我要重複的代碼
<transition on="create_user" to="create_user_page" />
<transition on="find_user" to="search_page" />
爲 「create_user_page」 和 「search_page」。是否有可能如何重寫它,同時牢記這些操作發生在這兩頁相同的「標題」中。
感謝@ rootkit007的答案。一個小的澄清:對於「內容」我有不同的頁面。所以我想顯示另一個頁面,而不是重新渲染同一頁面。據我所知,如果你想重新渲染同一頁面或者我錯了,「部分渲染」是合適的? – chaldaean 2013-02-19 10:35:47
我添加了XHTML示例。部分渲染適合重新渲染當前頁面的某些部分,而無需刷新其他所有內容,這是正確的 – rootkit 2013-02-19 18:41:25