如何更新从备用Bean生成的ID [英] How to update id generated from a backing bean
本文介绍了如何更新从备用Bean生成的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<p:outputPanel>
<h:selectOneRadio value="#{myBean.favColor1}">
<f:selectItem itemValue="Red" itemLabel="Color1 - Red" />
<f:selectItem itemValue="Green" itemLabel="Color1 - Green" />
<f:selectItem itemValue="Blue" itemLabel="Color1 - Blue" />
</h:selectOneRadio>
<p:ajax update="picker,#{myBean.clientId}"/>
</p:outputPanel>
我需要更新其ID是通过编程生成的组件.
I need to update a component whose id is generated programmatically.
推荐答案
客户端ID应该以默认的命名容器分隔符:
为前缀,以便将其绝对解析为UIViewRoot
而不是相对于父命名容器(适用于组件ID,但不适用于客户端ID).
The client ID should be prefixed with the default naming container separator character :
so that it will be resolved absolute to the UIViewRoot
instead of relative to the parent naming container (which will work for component IDs, but not for client IDs).
<p:ajax update="picker,:#{myBean.clientId}"/>
作为另一种完全不同的选择(我发现将客户端ID绑定到非常痒的后备bean),只需将组件绑定到视图并引用它即可,而不是通过中间托管bean.
As a completely different alternative (I find binding the client ID to a backing bean pretty itchy), just bind the component to the view and reference it instead of through an intermediary managed bean.
<h:someComponent binding="#{foo}" />
...
<p:ajax update="picker,:#{foo.clientId}"/>
这篇关于如何更新从备用Bean生成的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文