Search code examples
richfacesajax4jsf

data-* attributes with a4j:commandLink


What is an equivalent data-* attribute that can be added with a4j:commandLink in richfaces 3.3. I have simple data-toggle="dropdown" from materializeCSS but server throws an error for data-toggle when I include it as below:

<a4j:commandLink ajaxSingle="true" 
    styleClass="dropdown-toggle" data-toggle="dropdown">
</a4j:commandLink>

Any work around for this attribute in richFaces or should I be including it in any other html element?


Solution

  • There is no equivalent, <a4j:commandLink> is not a HTML element and JSF (at least in 2.0+) will simply ignore any attribute it doesn't recognize.

    JSF 2.2 has passthrough attributes, where you can do this:

    // xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
    
    <h:commandLink pt:data-toggle="dropdown">
    

    That said, even if it works with RichFaces which I'm not sure it does - why do you want to turn an <a4j:commandLink> into a dropdown? If you're not going to be sending any AJAX requests simply use a link, if you are then RichFaces already has a dropdown menu.