1 Reply Latest reply on Mar 11, 2013 4:28 AM by lfryc

    Evaluating .ecss resource programatically

    amitev

      Hi all! I'm creating a functionality that creates a single combined css file from all the css files used in the current view (using custom h:head renderer).

      I get all css files from the classpath and store them as a single css file internally and serve it to the browser. However the ecss resources cannot be extracted directly, they have to be evaluated first because they are dynamic and contain EL expressions. Currently i perform an internal http request from the server to the server requesting the ecss file from the server where it gets evaluated by the API using a URLConnection. Is there a better/more proper way to evaluate such ecss resource using some internal API without performing additional HTTP request?

        • 1. Re: Evaluating .ecss resource programatically
          lfryc

          Hey Adrian,

           

          the ECSS resource can be evaluated using createCompiledCSSResource method

           

          but you need to call createResource method because of visibility issue.

           

          However you need to obtain the instance of ResourceFactoryImpl first - it's not available from the context, so you can access it via ResourceHandlerImpl#createResource method which delegates to ResourceFactoryImpl instance.

           

          RichFaces' resource handler can be obtained using FacesContext.getApplication().getResourceHandler();

           

          At the end, you can use Resource#getInputStream() on created Resource object in order to evaluate ECSS resource.