jsf - 如何获取知道其 id 的 jsf 组件父级的 id?
问题描述
我有一个<h:commandLink id="link1" ..>
内一个<div id="div1">
。我想得到这个 div 的 id(<h:commandLink id="link1" ..>
支持 bean 的父元素,我不想直接得到它,但我想让它通过它的 child( )。
请问我怎么能做到这一点。在这里您可以找到我的代码示例。
<div style="text-align:center; height: 50px; width: 100%; background: wheat;
border: 1px #6e5d40 solid; margin-top: 5px;">
<h:form>
<ui:repeat var="label1" value="#{backingBean.listOfSearchValue}">
<span class="filterLabel">#{label1} <h:commandLink class="glyphicon glyphicon-remove"></h:commandLink>
</span>
</ui:repeat>
</h:form>
</div>
解决方案
Don't just use a plain HTML div
, but use a h:panelGroup layout="block"
. Then it is just a matter of getting the parent of the UIComponent
(the button in your case).
See also OmniFaces Components
for help with finding components from within your bean, especially getClosestParent(UIComponent component, Class<C> parentType)
.
推荐阅读
- kubernetes - 掌舵升级时缺少图表元数据(Chart.yaml)
- jenkins - “@”字符使詹金斯错误无法解析文件
- python - 如何计算5分钟间隔的平均温度?
- angular - 如何在不多次订阅的情况下从服务中获取新的更新值
- apache-spark - 如果 Spark 支持内存溢出到磁盘,Spark Out of Memory 怎么会发生?
- ios - Siri Intent 扩展在现有应用程序中不起作用
- angular - 延迟加载时找不到模块错误
- javascript - 快速调用点击事件时随机出现类型错误
- c++ - 如何使用 std::pair 作为 std::map 中的键?
- yii2 - 如何在 yii2 中为模块创建前端和后端结构?