[英]Reuse some .xhtml pages on a JSF primefaces application
我使用JSF和PrimeFaces開發一個簡單的應用程序,這是我面臨的一個問題:
這些是具有Person
屬性的托管bean:
ClientBean
EmployeeBean
我有person.xhtml
顯示來自一個人的數據。 我包括person.xhtml
上client.xhtml
和employee.xhtml
。 我需要創建兩個person.xhtml
因為我使用不同的bean。 我想做的是這樣的:
<c:set var="person" value="clientBean.person" />
<ui:include src="person.xhtml"/>
<c:set var="person" value="employeeBean.person" />
<ui:include src="person.xhtml"/>
在我的person.xhtml
我可以使用#{person.name}
, #{person.dateOfBirth}
。 我搜索並在JSF中使用<c:set/>
是錯誤的。
有人可以幫忙嗎?
將其作為<ui:param>
傳遞。
<ui:include src="person.xhtml">
<ui:param name="person" value="#{clientBean.person}" />
</ui:include>
<ui:include src="person.xhtml">
<ui:param name="person" value="#{employeeBean.person}" />
</ui:include>
如果需要,將person.xhtml
注冊為標記文件以使其看起來更好,另請參閱何時使用<ui:include>,標記文件,復合組件和/或自定義組件?
<my:personForm value="#{clientBean.person}" />
<my:personForm value="#{employeeBean.person}" />
注意重復的組件ID錯誤。 另請參閱在同一命名容器中重用facelets組合時避免重復的ID 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.