Obtaining the clientId of the parent of a JSF2 composite component

前端 未结 1 1552
终归单人心
终归单人心 2021-01-24 03:14

I\'ve got the following code:


    
        #{entry.title}
             


        
相关标签:
1条回答
  • 2021-01-24 03:53

    Use #{cc.parent.clientId} instead. All content inside composite:implementation is inside a UIPanel that is on a facelet inside the composite component base instance, which usually is a NamingContainer.

    UPDATE: Checking the code, cc.parent resolves the parent composite component instead of the immediate parent. It seems to be an old implementation detail, but it is not mentioned in the spec. The solution proposed in this answer does not work :(.

    See http://lists.jboss.org/pipermail/jsr-314-open-mirror/2010-February/002474.html

    You can bypass the resolution of cc.parent, providing a custom component class extending UINamingContainer and adding this:

    <composite:interface componentType="my.custom.ComponentBaseClass">
    

    then add a getter like

    public UIComponent getImmediateParent()
    {
         return getParent();
    }
    

    and finally use #{cc.immediateParent.clientId}. It should work in this way.

    0 讨论(0)
提交回复
热议问题