如何创建一个不是 NamingContainer 的复合组件
我创建了一个复合组件来替代项目中的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需给复合组件一个固定的 id,这样 JSF 就不会自动生成它。
不,您无法禁用它。否则就不可能在同一视图中使用多个复合组件。另一种方法是使用 Facelets 标记文件。但这不允许对属性、操作、方面等进行细粒度的声明和更好的定义。
Just give the composite component a fixed id so that JSF won't autogenerate it.
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.