p:commandButton with custom attributes

UI Components for JSF
Post Reply
elfwine
Posts: 1
Joined: 16 May 2017, 10:33

11 Jan 2018, 03:03

Is there any way to add a 'data attributes' to p:commandButton?

I tried the following settings but data attributes aren't rendered.

Code: Select all

<p:commandButton value="Submit" action="#{top.changeMenu()}" data-idx="1" data-menu="top" process="@this" />
and this,

Code: Select all

<p:commandButton value="Submit" action="#{top.changeMenu()}" process="@this" >
    <f:attribute name="data-idx" value="1" />
    <f:attribute name="data-menu" value="top" />
</p:commandButton>
I'd like the button to be something like this when rendered,

Code: Select all

<input type="submit" value="Submit" class="btn" data-idx="1" data-menu="top" />
Please let me know if it's possible to do.

Thanks a lot.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

11 Jan 2018, 10:41

google for "jsf passthrough attributes" ;)
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests