将元素添加到 commandButton 值

Adding element to commandButton value

我想在 JSF 中创建这样的按钮。

<button class="btn btn-primary">
  <i class="fa fa-check"></i> 
  Save
</button>

但是h:commandButton 只允许在名为"value" 的属性中设置按钮的值。所以我试着像这样创建我的按钮:

<h:commandButton class="btn btn-primary" value="<i class='fa fa-check'></i>Save" action="#{bean.save}" />

并得到错误:

Error The value of attribute "value" associated with an element type "h:commandButton" must not contain the '<' character.

如何在 h:commandButton 中嵌入 HTML?

你有这样的用法

    <h:commandLink  style="width:20px;height:15px;" action="#{bean.smethodName()}"
      <i class="fa fa-searchfaicon2x"></i>                                    
    </h:commandLink>

按钮相同

<h:commandButton class="btn btn-primary" value="Save" action="#{bean.save}">
<i class='fa fa-check'></i>
</h:commandButton>