6

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 ブートストラップ リンクを次に示します: http://twitter.github.com/bootstrap/components.html#alerts

4

3 に答える 3

7

メッセージを追加する通常の方法だと思います...

FacesContext context = 
FacesContext.getCurrentInstance(); 
context.addMessage(null, new FacesMessage(your message goes here...  

メッセージはサーバー側から追加する必要があります...例String myMessage = "here is the text / HTML code..."

BalusCによるこの記事を見てください

JSF メッセージでの HTML の使用

于 2012-05-03T12:45:42.603 に答える
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 にも適応できます。

于 2014-12-10T21:38:10.430 に答える