Phellipe Ribeiro
Phellipe Ribeiro

Reputation: 481

How to render a HTML button element in JSF 2.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.

Upvotes: 2

Views: 1983

Answers (2)

AsSiDe
AsSiDe

Reputation: 1846

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>

Upvotes: 3

Kuldeep Acharya
Kuldeep Acharya

Reputation: 11

<ui:fragment rendered="condition">
  button code...
</ui:fragment>

I think this will solve your issue

Upvotes: 0

Related Questions