覆盖 JSF Primefaces 消息标签
我是否可以覆盖
的默认实现,以始终隐式地使用 display="text"
而不是及时完整地输入?
<p:message for="hotelName" display="text" />
Can I override the default implementation of <p:message ../>
to always implicitly have display="text"
instead of typing out in full in time?
<p:message for="hotelName" display="text" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以为此扩展 PrimeFaces 的
MessageRenderer
。只需重写encodeEnd()
方法,在调用 super 方法之前设置默认属性即可。这是一个独立的启动示例:
您需要在 faces-config.xml 中注册,如下所示(不,注释魔法无法覆盖现有的渲染器,这些渲染器本身是由 XML 注册的,所以 XML 是绝对必要的):
但更简单的方法是添加一点 CSS 来隐藏图标。
按照另一个答案的建议创建复合组件并不完全是微不足道的,因为
的for
目标不包含在同一复合材料中。You could extend the PrimeFaces'
MessageRenderer
for that. Just override theencodeEnd()
method wherein you set the default attribute before calling the super method.Here's a self-containing kickoff example:
which you need to register in
faces-config.xml
as follows (no, annotation magic won't work in overriding the existing renderers which are by itself registered by XML, so the XML is absolutely necessary):But easier would be to just throw in a little bit of CSS to hide the icon.
Creating a composite component as suggested by the other answer isn't exactly trivial because the
for
target of the<p:message>
isn't contained within the same composite.我只需为此创建一个 Facelet 组合组件。
I would simply create a Facelet Composition Component for that.