Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF: Where do the technologies fit in?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had zero time to look into JSF to date. Could you give a brief overview of the technology? For example, how does it fit onto the HTTP request/response cycle? Does it (or how does it) utilize the servlet model? What processing happens where? Is it a JSP replacement or augmentation?
You also mentioned a navigation model in other threads; could you give a stratospheric view of how that operates?
thanks,
bear
 
Bill Dudney
Author
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
JSF is a Model 2 framework for doing web development. Which is just a fancy way to say that JSF does model-view-controller for the web. I have a bit of info about this in the presentation I did for NoFluffJustStuff. If you search on google you should find it on either my blog or my .mac account.
So the lifecycle looks something like this.
  • You click a button or a link
  • Server gets the form submit via normal HTTP stuff
  • Server sees the JSF tags in the URL (either /faces/* or *.jsf or something of your choosing) that says to forward the request to the FacesServlet.
  • FacesServlet does a bunch of stuff to get your components up and ready for events
  • Your application is called a well defined points in the processing
  • The logical outcome from the processing is matched against the nav rules (more on that latter)
  • JSF forwards to the page specified in the nav rules


  • From the 100000 foot range (stratosphere starts about there if I remember my earth science ) the navigation model lets you externalize the way users navigate through your application. So for example here in my Post A Reply form on JavaRanch there are two actions I can take, 'log out' and 'Add Reply'. If I were implementing this form with JSF these two 'actions' are UICommand components. One rendered as a link and one is rendered as a button. When the button click happens or the link is activated the form is submitted. On the back end the JSF machinery notices what happened and posts server side events. The events eventually boil down to a method call on one of the server side objects to a method that returns a String and takes no arguments. This string is called a 'logical outcome' in the spec. This logical outcome is then matched against the navigation rules in the faces-config.xml file. The rules basically say 'from some page with logical outcome XYZ go to page Foo.jsp'.
    I hope that helps!
     
    Gregg Bolinger
    GenRocket Founder
    Ranch Hand
    Posts: 15302
    6
    Chrome IntelliJ IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    That was a good explination. It's a lot like Struts. But as I understand from another post, it is Component driven whereas Struts is, well, I don't know what it is.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64712
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Cool, that answers the nav question pretty well, thanks.
    What about the JSP question: Is a "JSF page" a JSP page with JSF-provided custom actions? Or does JSF replace JSP with another templating language?
     
    Bill Dudney
    Author
    Ranch Hand
    Posts: 234
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'd call Struts 'custom action' based. Every bit of UI in struts is based on the tags.
    JSF uses JSP for the default templating language. However one of the examples that ships with RI shows you how to build the component tree (the view) with XML.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic