On 8/21/05, David G. Friedman <[EMAIL PROTECTED]> wrote: > Frank, > > I hate to try to answer a question after Craig, but from my JSF newbie point > of view, I didn't get an answer I'd want from his letter. So, here's my try > to help answer your questions. Just keep in mind I'm re-reading (2nd time > around) a JSF book so I'm no authority. > > MyFaces, JSF actually, doesn't care about action mappings, like Struts does. > When a url comes in which maps to JSF (or Myfaces) such as a *.faces URL, > JSF looks for a file matching that url but ending in .jsp, not .faces. > That's how /usecases.faces maps automatically to /usecases.jsp. >
FWIW, the actual mechanism is a little more flexible than this. If you are not using JSP as your view technology, you might want to define a different suffix (for the scenarios where you are using extension mapping, which is the preferred approach). For example, you can tell JSF to map the request "index.faces" to "index.foo" instead, by setting the following context init parameter in your webapp. <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.foo</param-value> </context-param> The default for this parameter maps to ".jsp", which suits the majority of JSF users, but it doesn't restrict you from other approaches. > Why does it do that? The mapping of *.faces allows MyFaces/JSF to do the > JSF tricks listed in the jsp file which could include bean auto-population, > page redirects, validations, navigations, callback functions, templates, > etc. A tree is made of the JSF components from that page so further visits > to that page don't require a rull re-parse of the page. In my opinion, JSF > navigation seems to care more about the direction of where to navigate next > than how to come into a page. You'll see loads of those 'where to next' > ideas in the faces-config.xml file as 'navigation-rule' sections. You don't actually *have* to be specific about where the navigation request came from, or what the outcome value are ... you can either leave those elements out of your navigation rule, or use one of the wildcard expressions. An example of this can be found in the use cases webapp: <navigation-rule> <from-view-id>*</from-view-id> <navigation-case> <from-outcome>subview$first</from-outcome> <to-view-id>/subview/first.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>subview$second</from-outcome> <to-view-id>/subview/second.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>subview$third</from-outcome> <to-view-id>/usecases.jsp</to-view-id> </navigation-case> </navigation-rule> This navigation rule processes the specified outcome values ("subview$first", "subview$second", or "subview$third") no matter what page you are currently on. > > A few useful tidbits of knowledge: > > 1. Everything JSF starts inside the f:view tags. > > 2. The *.faces don't have to map to *.jsp extension files. A servlet > container configuration parameter allows you to specify the default > extension to use so you could use something other than *.jsp for your actual > files. You can also change your incoming *.faces URL mapping to *.html to > hide the fact that you're using JavaServer Faces. > > 3. JSF can be sufficiently complicated to 'look at' if you haven't read a > JSF tutorial or book so jumping into Shale could be even more confusing. > Shale confuses me some and I've read a JSF book once (I'm on read #2 as I > mentioned). > > 4. There are plenty of JSF tutorials at www.jsftutorials.net. (I've read a > few of them, I'm reading about Facelets now - kind of a 'Shale Clay' > alternative.) This includes a section on their front page entitled: Golden > Collection for JSF Newbies. > > 5. navigation-rules got a little confusing for me when looking at JSF with > Tiles, especially with Shale's Tiles mapper. I think it (Shale's Tile > mapper) looks for a tile with a name very similar to the jsp name and if one > isn't found, it skips tiles and looks for a regular jsp instead. Craig > could comment on that if I'm wrong or off slightly but I think I just read > about that last week. > The precise rules are described in the JavaDocs for the mapper class, but they are basically: * Strip off any suffix on the specified to-view-id * Look up the resulting value in the Tiles definitions * If found, navigate to that Tile * If not found, and if the to-view-id has a leading "/", remove that and try again * If we still cannot find a Tile, delegate to the standard JSF navigation handler This basically lets you have any combination of Tile names and regular page names as your destinations for navigation rules. > 6. In case you need it, myfaces is at http://myfaces.apache.org. Tomahawk > if the name of their set of custom add-on components, which you don't need > if you are trying out JSF. You can just use the MyFaces (non-Tomahawk > stuff) implementation of JavaServer Faces. > Just for the record, the JSF RI is also available under an open source license, at java.net. Go to <https://javaserverfaces.dev.java.net/> and accept the CDDL license terms, and you'll be able to get to the source code. > Regards, > David > Craig > -----Original Message----- > From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] > Sent: Monday, August 22, 2005 12:53 AM > To: Struts User > Subject: [SHALE] Simple "getting started"-type question > > > Hi everyone, > > I'm finally getting a little bit of time to look at Shale, with the > intent of doing the Mailreader app under it as I offered to do a few > weeks back... although I was thinking of writing a blog app instead > since I wanted to re-do mine anyway, but that is neither here nor there :) > > I'm looking at the use cases app, as that seemed like the logical place > to begin... there's quite a bit in there, it's a bit overwhelming to > start, and, after just a few minutes of browsing, I have a question > already :) > > Looking at index.jsp, I see a forward to usecases.faces. My question > is, where is that mapping defined? It's obviously winding up at > usecases.jsp, and I can see that .faces is mapped to FacesServlet in > web.xml, so it's straight-forward to an extent, but I'm not seeing in > the config files were something akin to a Struts path to /usecases is > defined. I assumed it would be in faces-config.xml, but unless I'm > really missing something, it's not (by the way, I *DO* assume I'm > missing something there!). > > Thanks! > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]