Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

help to understand basic concept in JSF  RSS feed

 
Prakash Sam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help to understand basic concept in JSF

JSF is a MVC Frame work.


Why we did not use the file extension with jsf instead of filename.jsp? what will happen if i gave the file extension as filename.jsf
Why we are using View Technology as jsp or xul or xhtml in JSF?
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prakash,

The file extension to use in JSF is fully configurable. That means the choice is up to you! The code snippet below shows the relevant settings:

This example is from an application that uses Facelets instead of JSP as view technology. In Facelets, pages are most of the time defined in XHTML files, so .xthml is a sensible file extension then. If you're using JSPs as view technology, .jsp or .jspx are good choices. .jsf is also used in a lot of projects.

Best regards,
Bart Kummel
 
Prakash Sam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bart Kummel,

Thanks for reply, But still i have confusion
Please explain in brief, what is the difference between .jsf & .jsp? please provide a small example snipet with using .jsf & please tell me why most of the projects using xhtml instead of jsf? and how to configure .jsf file what we want to include.

Thanks in advance
prakash
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prakash,

The point is: there is no relation between the contents of the file and the extension. The contents of the file are determined by the choice between Facelets or JSP as view technology (see below). The file extension is determined by the url-pattern and the DEFAULT_SUFFIX setting. The extension can be anything you like. You could use the extension .prakash if you like.

So to answer your question about the difference between .jsf and .jsp: the difference is one character.

The choice between Facelets or JSP is a whole other story. To keep it short: for new projects you should always use Facelets. JSP was never designed for use with JSF. Therefore using JSP as view technology is sub-optimal. That's why Facelets was created. In JSF 2.0, Facelets is the default view technology.

Best regards,
Bart
 
Prakash Sam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bart Kummel wrote: Facelets or JSP as view technology


Hi Bart,

By this i understand that JSF cant able to act as view technology. JSF provide components(UI components), that components can access by facelets or jsp. am i correct? & please explain why JSF can't role as view technology?


Suggest me book to more about JSF & Facelets, and why JSF can't role as view technology?

thanks in advance,
Prakash
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prakash,

You're correct about JSF 1.2 needing Facelets or JSP as view technology. JSF is a component-oriented framework. It is designed to use a view technology as carrier for the components. So why doesn't JSF 1.2 have a view technology of its own? Simply because it wasn't designed to have one. For JSF 2.0 the story is a bit different, as in JSF 2.0 Facelets is now part of the JSF standard. I hope this answers your question.

I suppose you are aware that there is a book promotion running right now on this forum? The promotion is about the book i wrote: Apache MyFaces 1.2 Web Application Development. Although the book is not especially written for JSF beginners, I think you can use it as a step-by-step guide to get started with MyFaces and Facelets.

Best regards,
Bart
 
Prakash Sam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bart,

Thank you so much for your great reply, Now i got clear idea about JSF [View].

With Regards,
Prakash.
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bart Kummel wrote:Hi Prakash,

You're correct about JSF 1.2 needing Facelets or JSP as view technology. JSF is a component-oriented framework. It is designed to use a view technology as carrier for the components. So why doesn't JSF 1.2 have a view technology of its own? Simply because it wasn't designed to have one. For JSF 2.0 the story is a bit different, as in JSF 2.0 Facelets is now part of the JSF standard. I hope this answers your question.


I didn't know that JSP was never the standard view technology for JSF. Did your book discuss teaching Facelets in greater detail for newbie.
 
Bart Kummel
author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,

Up until JSF 1.2, JSP is the default view technology for JSF. However, JSP did already exist when JSF was created. So that's why JSP wasn't designed to be used as a view technology for JSF. JSF needed a view technology and I guess the guys who made the first JSF specs just picked the only Java view technology that was standardized and part of Java EE at that time. But, that's all history. The good news is that Facelets is far better and that it can be used with JSF 1.2. (Note that JSF 2.0 includes a newer and further improved version of Facelets as part of the standard.)

Regarding your question about my book: Chapter 3 of the book is dedicated to introducing Facelets. I think that chapter is an excellent starting point for a Facelets newbie. All following chapters do use Facelets in all code examples, making the rest of the book an great resource of Facelets examples. Much chapters pay special attention to getting the most out of Facelets combined with the MyFaces libraries.

Best regards,
Bart
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!