![](/img/trans.png)
[英]JSF / Primefaces composite component with nested composite component
[英]JSF Updating Composite Component (Primefaces)
我有以下UI Primefaces片段:
<pou:growl id="growl"
redisplay="false"
showDetail="false"
sticky="false" />
當我嘗試更新此項時,例如:
<pou:commandButton value="Update"
update=":growl"/>
一切正常。
當我將咆哮移動到復合組件然后嘗試調用它時(即像這樣):
<ez:growl/>
我得到一個錯誤消息說:
javax.faces.FacesException: Cannot find component with identifier ":growl" referenced from "j_idt84:j_idt85:testForm:j_idt111".
我的問題是為什么要添加所有這些自動生成的名稱以及如何控制它們以便我可以實際訪問要更新的組件?
這是因為復合組件固有地從UINamingContainer
擴展(如<h:form>
, <h:dataTable>
等),因此會為其子級的客戶端ID添加自己的ID。
要實現您的特定功能需求,請首先為復合組件提供固定ID:
<ez:growl id="growl"/>
然后將<p:growl>
嵌入到復合組件的實現中,在<div>
或<span>
類的純HTML容器元素中,復合組件的客戶端ID作為元素ID:
<cc:implementation>
<span id="#{cc.clientId}">
<p:growl />
</span>
</cc:implementation>
現在你可以通常的方式使用update=":growl"
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.