PrimeFaces integration

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

With 2.1.8 PrimeFaces integration improved. No configuration 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"



Code example

Take a look at

results matching ""

    No results matching ""