Search code examples
jsfjsf-2

JSF - <h:commandButton or equivalent to ouput <button> HTML output?


Is there a way for JSF to output something like this:

<button type="submit" ...></button>

I know that you are supposed to use <:hcommandButton /> normally but it outputs a <input type="submit"> instead and the front end developer wants to put a <i /> inside the button to have icons inside using font awesome.

Would be great if we could avoid using a custom component...it's pretty tedious.

Thanks.


Solution

  • Yes, it's the <h:button>.

    <h:button value="Label" outcome="page.xhtml" />
    

    PrimeFaces has a more customizeable one as <p:button>.

    Note that you can also just write down plain HTML in JSF and if necessary just wrap it in a composite component or a tag file.

    See also: