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

发布于 2024-12-20 08:25:34 字数 1536 浏览 5 评论 0原文

我创建了一个复合组件来替代项目中的 primefaces 弹出窗口。我在生成的html中发现了一些非常糟糕的东西,出现了一个奇怪的id,并且我找不到这个id从哪里开始,所以我怀疑这个id是由复合组件生成的。我需要删除这个 id 来刷新我需要的内容...... 那么,有没有办法可以禁用这个组件生成这个id?

举例说明:

<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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖凝香 2024-12-27 08:25:34

只需给复合组件一个固定的 id,这样 JSF 就不会自动生成它。

<hrgi:dialog id="foo" />

不,您无法禁用它。否则就不可能在同一视图中使用多个复合组件。另一种方法是使用 Facelets 标记文件。但这不允许对属性、操作、方面等进行细粒度的声明和更好的定义。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文