Hey Rick! It's nice to see a familiar name. Nice JSF example on your
site. I'm using it to see where the heck I'm screwing up.
Here's my directory set up:
/index.jsp
/css
/images
/javascript
/pages/launch.jsp
/WEB-INF
Here's a snippet from my web.xml
---------------------------------------------------------
<snip>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</snip>
Here's a snippet from my faces-context.xml file.
This is really the only thing I have in it besides the doctype.
----------------------------------------------------------
<faces-config>
<navigation-rule>
<navigation-case>
<to-view-id>/pages/launch.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Here's my index.jsp file:
----------------------------------------------------------
<jsp:forward page="/launch.faces"/>
This set up produces a 404 error:
-----------------------------------------------------------
HTTP Status 404 - /launch.jsp
type Status report
message /launch.jsp
description The requested resource (/launch.jsp) is not available.
Notices there is no mention of "/pages" directory in the error message.
Now, if I copy or move the /pages/lauch.jsp to /launch.jsp AND make no
other changes, redeploy. The page is found and is rendered. As long as
launch.jsp resides directly under the webapp root context, I can even
change <to-view-id>/pages/launch.jsp</to-view-id> to
<to-view-id>/launch.jsp</to-view-id> and it is found. It's as if the
"/pages" part of the view-id is being stripped out.
I'm going to have a look at the source in
org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl
to see if I can tell what's happening.
Any ideas? Have you seen any examples where the pages reside in a
subdirectory instead of directly under the web app root context?
I running Tomcat 5.5.9, JDK 1.4.2, on Win2K, with MyFaces 1.0.9.
/robert
Rick Reumann wrote:
Robert Taylor wrote the following on 9/15/2005 6:12 PM:
Greetings, I'm a current Struts user interested in learning and using
MyFaces and JSF.
My dev. env. consists of Tomcat 5.5.9, MyFaces 1.0.9, JDK 1.4.2, Win2K.
I've configured MyFaces to use Tiles for view-handler.
What I want to do is to have my welcome page (index.jsp), forward to a
launch page for the application.
In Struts, I would simply use a <jsp:forward page="/app/launch"/>.
In my struts-config.xml file I has an action mapping for <action
path="/launch" forward="launch.tile"/> which forwarded to a tiles
configuration which builds the page.
I'm trying to do something similar with JSF, but have been unsuccessful.
I removed the "tiles" complexity just to see if it would display a
non-tiles .jsp. My wecome page consists of a single line:
<jsp:forward page="/app/launch"/>.
My faces-context.xml file is as follows:
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd" >
<faces-config>
<navigation-rule>
<from-view-id>/launch</from-view-id>
<navigation-case>
<to-view-id>/pages/launch.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
How's it going Robert. Good to see you here:)
I'm not totally sure of the interaction/effects of using .faces
(assuming you have in you web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
)
but what should work is....
<jsp:forward page="/app/launch.faces"/>
<navigation-rule>
<navigation-case>
<from-outcome>app/launch</from-outcome>
<to-view-id>/pages/launch.jsp</to-view-id>
</navigation-case>
</navigation-rule>
Someone please correct if what I'm doing above is the wrong approach (as
I'm using it in the online example I wrote and I want to be doing the
correct thing http://www.reumann.net/reumann/jsf/jsf_employees/ )