• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Getting Started with JavaServer Faces 2.0: Text and Video Tutorials

 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I just posted a new article up on TheServerSide.com about getting started with JSF 2.0 development. However, for some reason, the new V7 content management system keeps messing up the <PRE> tags that handle Java code and XML. Yes, don't say it, because I'm already thinking it. So, I'm just going to post the XML and HTML code in the order they appear in the article right here, and reference it from that post on TSS. Also, I thought I'd link to this thread from the article so anyone who has any questions can ask away.

Here's the article at TheServerSide.com: Slingshot Yourself into JSF 2.0 Development by Cameron McKenzie & Sal Pece

There's also a video of the tutorial at TheServerSide.

And here's the follow-up tutorial on handling user input with ManagedBeans: Handing User Input in JSF 2.0 (JSF without XML)

Here's the web.xml file:



The faces-config.xml File (not needed)


The helloworld.xhtml File


Here's how I warred up the content:

And here's the URL I used to run it:

Okay, I think that just about does it. Hopefully that will help the readers of the article.

By the way, you can also view a high resolution video of the tutorial here: Video Tutorial on Getting Started with JSF 2.0

 
author
Posts: 82
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good stuff. Note that in Mojarra, the web.xml is optional too. We actually specified that in JSF 2.1, but it is also implemented in Oracle Mojarra 2.0.
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Who is this "Ed Burns" guy, and how can he go around saying the web.xml file is optional?

I never even entertained that idea that a web.xml file would be optional, as the whole thing does get deployed as a war file to a servlet engine. How would the servlet engine know to map a given request to the faces framework without at least mapping the FacesServlet or adding some type of listener to the web.xml file? Is there a quick link or resource that would explain this 'heretic magic' of which you speak?

By the way Ed, on my site I recommend your book as one of the two books any JSF developer needs to get if they're doing JSF development, and that's before I even suggest picking up a copy of the JSF Made Easy book I'm coming out with.

Thanks for the 'props' on the tutorial. I have a number of them in the works with the goal of helping and encouraging people to explore, adopt and get excited about working with JSF. Here's hoping it works.

-Cameron McKenzie
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm...Seems like this 'Ed Burns' guy just might know what he's talking about.

Indeed, in JSF 2.1 there's some heavy promotion of the fact that the web.xml file is optional in a JavaServer Faces application.

Here's what the aquarium says about it:

In the case of GlassFish v3.0, web.xml is optional and there is no longer the need to declare the Faces servlet



-The Aquarium

Cay has written a bit about it in his blog:

GlassFish automatically provides a JSF servlet mapping for the /faces/*, *.faces, and *.jsf patterns, provided that any of the following conditions applies:

*Any of the classes in the web application uses a JSF 2.0 annotation
*Any initialization parameters start with javax.faces
*The WEB-INF/faces-config.xml file is present

Isn't it grand? Now you can have a JSF app without web.xml or faces-config.xml, just a bunch of .xhtml pages and Java classes annotated with @ManagedBean.

The only fly in the ointment is that, if you really want to be thoroughly modern and use web beans, erm, JSR 299 Contexts and Dependency Injection, then you should still leave something in place to trigger the servlet mapping.



Cay's Blog

Most of the talk here is that "Glassfish" automatically maps the FacesServlet. Now my question is whether this is just a sweet thing Glassfish designers decided, or whether this is just part of the Java EE specification. Since I can't seen the people at GlassFish doing this just out of the good of their heart, my assumption is that it is a Java EE requirement?

I'm currently deploying to Apache Tomcat 7, so my guess is that since Tomcat 7 is only a Servlet Engine, and not a full blow Java EE server, for Tomcat I'd still need the mapping.

Interesting stuff!
 
Ed Burns
author
Posts: 82
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It was an impl feature in 2.0. It is required behavior in 2.1.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic