簡體   English   中英

在JSF primefaces應用程序上重用一些.xhtml頁面

[英]Reuse some .xhtml pages on a JSF primefaces application

我使用JSF和PrimeFaces開發一個簡單的應用程序,這是我面臨的一個問題:

這些是具有Person屬性的托管bean:

  • ClientBean
  • EmployeeBean

我有person.xhtml顯示來自一個人的數據。 我包括person.xhtmlclient.xhtmlemployee.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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM