简体   繁体   中英

How create a composite component that isn't a NamingContainer

I've create a composite component to substitute primefaces popup in my project. I've found something really bad in the generated html, an strange id appears and I can't find where this id is beggining, so I suspect this id is generated by composite component. I need remove this id to refresh just the content I need... So, is there a way I can disable this component generate this id??

for ilustration:

<c:interface>
    <c:attribute name="titulo" default="sem titulo" required="false" />
    <c:attribute name="renderizar" default="false" required="false" />
    <c:facet name="conteudo" />
</c:interface>

<c:implementation>
    <h:outputStylesheet library="css" name="hrgiPopup.css" target="head" />
    <h:outputStylesheet library="css" name="clearfix.css" target="head" />
    <h:outputScript library="js" name="hrgiPopup.js" target="head" />
    <h:panelGroup layout="block" rendered="#{cc.attrs.renderizar}"
    class="hrgi-dialog-panel clearfix">
    <h:panelGroup layout="block" class="hrgi-dialog-overlay clearfix"></h:panelGroup>
    <h:panelGroup layout="block" class="hrgi-dialog-box clearfix">
        <h:panelGroup layout="block" class="hrgi-dialog-title clearfix">
            <h:outputLabel style="float:left" value="#{cc.attrs.titulo}" />
        </h:panelGroup>
        <h:panelGroup layout="block" class="hrgi-dialog-background clearfix">
            <h:panelGroup layout="block" class="hrgi-dialog-content clearfix">
                <c:renderFacet name="conteudo" required="true" />
            </h:panelGroup>
        </h:panelGroup>
    </h:panelGroup>
</h:panelGroup>

Just give the composite component a fixed id so that JSF won't autogenerate it.

<hrgi:dialog id="foo" />

No, you can't disable it. It would otherwise not be possible to use multiple composite components in the same view. An alternative is to use a Facelets tag file instead. But this doesn't allow for fine grained declaration and nicer definition of attributes, actions, facets, etcetera.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM