2

I really need to render a <button> element under JSF 2.2 and I wouldn't like to use third party libraries--such PrimeFaces--just for this.

Once Mojarra's <h:commandButton> only renders <input> elements, is there any native/elegant solution to fulfil that requirement?

So far I've discovered this very similar question here on SO but for JSF 2.1, and 2.2 might have received some update on this matter.

Community
  • 1
  • 1
Phellipe Ribeiro
  • 491
  • 3
  • 13

2 Answers2

3

You can use <button> tag with JSF passthrough elements.

Define a new XML namespace

xmlns:jsf="http://xmlns.jcp.org/jsf"

In your html use this tag.

<button type="button" jsf:id="btn" jsf:outcome="yourViewIDHere">Test Button</button>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
AsSiDe
  • 1,826
  • 2
  • 15
  • 24
0
<ui:fragment rendered="condition">
  button code...
</ui:fragment>

I think this will solve your issue