我正在使用Twitter Bootstrap。
提醒HTML代码为:
<div class="alert alert-block">
<a class="close" data-dismiss="alert" href="#">×</a>
<h4 class="alert-heading">Warning!</h4>
Best check yo self, you're not...
</div>
我正在使用<h:messages />
来显示我的表单错误,信息和警告消息,如下所示:
<h:messages errorClass="alert alert-error" infoClass="alert alert-info" warnClass="alert alert-warning"/>
颜色和圆角都可以,但我需要添加关闭链接:
<a class="close" data-dismiss="alert" href="#">×</a>
如何使用<h:messages/>
?
修改
如果需要更好的理解,这里是警报样式的twitter bootstrap链接: http://twitter.github.com/bootstrap/components.html#alerts
答案 0 :(得分:7)
看看BalusC的这篇文章
答案 1 :(得分:3)
只需使用omnifaces o:messages。问题将得到解决。
例如<o:messages escape="false"/>
答案 2 :(得分:0)
另一种解决方案是
<div class="alert alert-danger alert-dismissible fade in" role="alert" jsf:rendered="#{not empty facesContext.getMessageList('InputPassword')}">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>Error </strong> <h:message for="InputPassword" />
</div>
它适用于JSF 2.2,但您可以适应以前版本的JSF ..