简体   繁体   English

如何创建不是NamingContainer的复合组件

[英]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. 我在生成的html中发现了一些非常糟糕的东西,出现了一个奇怪的ID,并且找不到该ID的起始位置,因此我怀疑此ID是由复合组件生成的。 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?? 我需要删除此ID以仅刷新所需的内容...因此,有没有一种方法可以禁用此组件来生成此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. 只需给复合组件一个固定的id,这样JSF就不会自动生成它。

<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. 一种替代方法是改用Facelets标记文件。 But this doesn't allow for fine grained declaration and nicer definition of attributes, actions, facets, etcetera. 但是,这不允许细粒度的声明以及对属性,操作,构面等的更好定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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