Simple showcase to combine PrimeFaces and ButterFaces in one webapp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PrimeFaces integration

As well as ButterFaces PrimeFaces comes with jQuery. This does not work out of the box.


With ButterFaces 2.1.8 no additional configuration is needed. It just works out-of-the-box. For further version look below.


ButterFaces deliveres css and javascript as first part of html head to allow custom class handling. PrimeFaces deliveres its own jQuery after ButterFaces, so ButterFaces jQuery plugins does not work anymore.


You can add your own version of jQuery or use jQuery from ButterFaces. You have to disable jQuery from PrimeFaces. Unfortunately you can not disable jQuery by a simple web.xml parameter (like in ButterFaces), but you can remove it from head by a javax.faces.event.SystemEventListener.

package de.larmic.butterfaces.primefaces.event;

import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;

public class HandleResourceListener implements SystemEventListener {

    public boolean isListenerForSource(Object source) {
        return source instanceof UIViewRoot;

    public void processEvent(SystemEvent event) throws AbortProcessingException {
        final UIViewRoot source = (UIViewRoot) event.getSource();
        final FacesContext context = FacesContext.getCurrentInstance();

        for (UIComponent resource : source.getComponentResources(context, "head")) {
            final String resourceLibrary = (String) resource.getAttributes().get("library");
            final String resourceName = (String) resource.getAttributes().get("name");
            if ("primefaces".equals(resourceLibrary) && "jquery/jquery.js".equals(resourceName)) {
                source.removeComponentResource(context, resource);

Activate it in your faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0"



Start showcase

mvn clean package wildfly-swarm:run