try {
// Check for an ajax4jsf filter.
Class<? extends Filter> ajaxFilterClass = contextClassLoader
.loadClass("org.ajax4jsf.Filter").asSubclass(Filter.class);
Filter ajaxFilter = ajaxFilterClass.newInstance();
FilterContainer filterContainer = new FilterContainer(ajaxFilter,
facesServletContainer);
filterContainer.setName("ajax4jsf");
facesServer.addResource("/WEB-INF/web.xml",
"org/richfaces/test/ajax-web.xml");
facesServer.addServlet(filterContainer);
} catch (ClassNotFoundException e) {
// No Richfaces filter, uses servlet directly.