Reputation: 53
I'm currently having trouble exposing my JSF files from the browser URL. My project structure goes something like this:
<PROJECT_NAME>
--->WebContent
--->index.xhtml
--->subfolder1
--->subjsf.xhtml
--->subfolder2
--->subjsf.xhtml
--->subfolder3
--->subjsf.xhtml
Here's my web.xml:
<?xml version="1.0"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>PROJECT_NAME</display-name>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>blueSky</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/pages/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
My faces-config:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>subfolder1</from-outcome>
<to-view-id>/subfolder1/subjsf.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<application>
<resource-bundle>
<base-name>resources</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>
Without using a redirect, it seems to work fine. But enabling redirect gives this error:
com.sun.faces.context.FacesFileNotFoundException: /subjsf.xhtml Not Found in ExternalContext as a Resource
When you access the URL directly something like this: <hostname>:<port>/PROJECT_NAME/subfolder1/subjsf.xhtml it also gave the same error above.
I want to enable the redirect for the URL to refresh and display the current page name. Also, is there a way to use implicit navigation with sub folders?
Really appreciated your help guys! Thank you in advance...
Upvotes: 2
Views: 5244
Reputation: 5654
As long as the content is not under WEB-INF, all the content should be directly accessible to the client.
Here are some tips to troubleshoot:
xhtml
content correctly outside WEB-INF ?Finally, you could go to the deployment directory, copy the WAR to a separate folder, deflate it and check if its content is as you expected.
Upvotes: 2