4 Replies Latest reply on Jun 10, 2010 5:19 PM by Edouard Edouard

    Filtering the integration of richfaces

    Edouard Edouard Newbie



      I have a simple problem and I hope you can help me with it. I'm working on a mobile version of a website which is using RichFaces.

      My project is a subfolder of the original website.

      One of the requirement is not to use any javascript, and so, my version doesn't use any of the Richfaces component.

      The problem is that the Richfaces CSS and Scripts files are still included. Is there a way to filter which pages have those files included?






        • 1. Re: Filtering the integration of richfaces
          Ilya Shaikovsky Master









          to NONE.

          • 2. Re: Filtering the integration of richfaces
            Edouard Edouard Newbie



            I'm sorry for the duplicate post, I saw this one after posting: http://community.jboss.org/thread/151559?tstart=30


            which basically answered my question. My problem now, is to include the right scripts and styles from richfaces, from the part of my project that need it.


            Ilya Shaikovsky:

            check loadStyle loadScript at richfaces-demo. them designed to fetch resources from jar's so you will be able to load our scripts and styles manually where need.


            I didn't find these load methods, and it sounds like I have to find which component use which script / style. Is there a way or reference to know that? And can you indicate me please where those methods are described?


            Thank you very much

            • 4. Re: Filtering the integration of richfaces
              Edouard Edouard Newbie

              Hi, thank you for your help.


              I finally figured out a simple way of really filtering the use of RichFaces. I just created a simple filter, replaced the org.ajax4jsf.Filter with this one, and I'm making a conditionnal call to it if I need it. As I described before, I just need to get ride of it for my mobile subdomain, so my condition is really simple:


              public class RichFacesFilter implements javax.servlet.Filter{


                  // The richfaces filter

                  private org.ajax4jsf.Filter richfacesFilter;


                  public void init(FilterConfig filterConfig) throws ServletException {

                      // Initiating the richfaces filter

                      richfacesFilter = new org.ajax4jsf.Filter();

                      richfacesFilter.init( filterConfig );



                  public void destroy() {

                      // destroy the filter


                      richfacesFilter = null;



                  public void doFilter(ServletRequest req, ServletResponse rep,

                          FilterChain chain) throws IOException, ServletException {


                      HttpServletRequest request = (HttpServletRequest) req;

                      String page = request.getRequestURI();

                      // IS PAGE FROM MOBILE SUBDOMAIN?

                      if( ! page.toLowerCase().contains("/mobile/") )

                          // NO: we run the richfaces filter

                          richfacesFilter.doFilter( req , rep , chain );


                          // YES: We don't run the richfaces filter

                          chain.doFilter( req , rep );





              I hope it might help someone.