Should a composite component really require namingcontainer interface?

为君一笑 提交于 2019-12-06 09:28:05
BalusC

Should a composite component really require namingcontainer interface?

Yes. Otherwise you would end up with "Duplicate component ID" errors coming from the composite component implementation when using multiple of them in the same parent naming container.

If you're absolutely positive that you don't want a NamingContainer based component, then rather create a tag file instead. It only requires some .taglib.xml boilerplate.

See also:


Another try but don't works. p:commandbutton can't see id of div inside of CC

Your composite implementation is invalid. In order to reference a composite properly by ajax, you need a plain HTML <div> or a <span> with exactly the ID of #{cc.clientId}.

E.g.

<composite:implementation>
    <div id="#{cc.clientId}">
        #{currentDate}
        <h:panelGroup layout="block">
            <p:outputLabel id="#{cc.clientId}_lb" value="#{cc.attrs.title}">
                <composite:insertChildren />
            </p:outputLabel>
        </h:panelGroup>
    </div>
</composite:implementation>

(I have by the way the impression that the <h:panelGroup> is superfluous, you can safely omit it; further the id="#{cc.clientId}_lb" can better be id="label" or something to minimize repetition/duplication)

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!