JSF更新复合组件(Primefaces) [英] JSF Updating Composite Component (Primefaces)
问题描述
我有以下UI Primefaces代码段:
I have the following UI Primefaces snippet:
<pou:growl id="growl"
redisplay="false"
showDetail="false"
sticky="false" />
当我尝试更新此项时,例如:
When I try to update this item, for example like this:
<pou:commandButton value="Update"
update=":growl"/>
一切正常.
但是,当我将咆哮声移至复合组件并尝试调用它时(例如,这样):
When I move growl to a composite component however and try to call it (ie. like this):
<ez:growl/>
我得到一个错误消息,内容为:
I get an error maessage that says:
javax.faces.FacesException: Cannot find component with identifier ":growl" referenced from "j_idt84:j_idt85:testForm:j_idt111".
我的问题是,为什么要添加所有这些自动生成的名称?如何控制它们,以便实际上可以访问要更新的组件?
My question is why are all these auto generated names being added and how can I control them so I can actually access the components to update?
推荐答案
It's because composite components inherently extend from UINamingContainer
(like as <h:form>
, <h:dataTable>
, etc) and thus prepend the client ID of their children with own ID.
要满足您的特定功能要求,请首先为复合组件指定一个固定ID:
To achieve your particular functional requirement, first give your composite component a fixed ID:
<ez:growl id="growl"/>
然后将<p:growl>
嵌入到复合组件的实现中的普通HTML容器元素(如<div>
或<span>
)中,并将复合组件的客户端ID作为元素ID:
Then embed the <p:growl>
in the composite component's implementation in a plain HTML container element like <div>
or <span>
with the composite component's client ID as element ID:
<cc:implementation>
<span id="#{cc.clientId}">
<p:growl />
</span>
</cc:implementation>
现在,您可以按常规方式使用update=":growl"
.
Now you can just use update=":growl"
the usual way.
这篇关于JSF更新复合组件(Primefaces)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!