Pergunta

I'm learning how to use icefaces so I created few simple applications using icefaces wiki tutorials. The problem is that css attached to jsf page isn't visible (error 404 after trying to open css address). According to icefaces information from here

To use a predefined theme style sheet with an ICEfaces application, all the page developer needs to do is add the desired CSS link to the page. [...]

<ice:outputStyle href="./xmlhttp/css/xp/xp.css" rel="stylesheet" type="text/css" />
Note: In the examples above, the xmlhttp/css/xp/ path is automatically resolved by ICEfaces and all needed resources are loaded from the ICEfaces.jar. 

I've added <ice:outputStyle> to my jsf page like this:

<h:head>
        <ice:outputStyle href="./xmlhttp/css/xp/xp.css" rel="stylesheet" type="text/css" />
</h:head>

I've created project using gradle and those are my dependencies used by the project (downloaded from maven central repo):

dependencies {
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.sun.faces:jsf-api:2.2.2'
    compile 'com.sun.faces:jsf-impl:2.2.2'
    compile 'org.icefaces:icefaces:3.3.0'
    compile 'org.icefaces:icefaces-compat:3.3.0'
    compile 'org.icefaces:icefaces-ace:3.3.0'
}
Foi útil?

Solução

You need to add the following servlet mapping for CompatResourceServlet in web.xml to make the compatibility components work.

 <!-- Many of the ICEfaces Components make use of the Resource Servlet -->
<servlet>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- These specific mappings are necessary for the Resource Servlet to function properly -->
<servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    <url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top