如何知道其ID的jsf组件父代的ID?

时间:2018-06-29 09:06:08

标签: jsf managed-bean

我在<h:commandLink id="link1" ..>中有一个<div id="div1">。我想获取此div(后备bean中<h:commandLink id="link1" ..>的父元素的ID,我不想直接获取它,但希望它通过其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>

1 个答案:

答案 0 :(得分:0)

不仅使用纯HTML div,还使用h:panelGroup layout="block"。然后,只需获取UIComponent(在您的情况下为按钮)的父代即可。

另请参阅OmniFaces Components,以获取有关从bean中查找组件的帮助,尤其是getClosestParent(UIComponent component, Class<C> parentType)

相关问题