Search code examples
jsficonscommandbutton

Adding element to commandButton value


I want to create such button in JSF.

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

But h:commandButton only allow to set the value of the button in attribute called "value". So I tried to create my button like that:

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

And got the error:

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

How can I embed HTML in h:commandButton?


Solution

  • You have use like this

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

    Same for button

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