3

I am trying to create a composite component in JSF and I want the file type as .jspf instead of .xhtml and all the examples I came across online are XHTML. I was just curious whether we can write composite component using JSP or not?

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
RegisteredUser
  • 380
  • 6
  • 18

1 Answers1

4

No, that's not possible. A composite component is specific to the Facelets 2.0 view technology (or "XHTML", as you incorrectly overgenerified it). Facelets is basically the successor of the legacy JSP view technology. JSP is been deprecated as view technology since JSF 2.0.

In JSP, closest what you can get to achieve this is a tag file. See also this answer for a concrete example: JSF 1.2 custom component from jsp:include.

Or better, just migrate to Facelets. It offers so much more templating advantages over JSP.

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • can I use facelets in jsf 1.2?? – RegisteredUser Oct 02 '12 at 15:07
  • +1 for a detailed answer with lots of useful links thanks !! :) – RegisteredUser Oct 02 '12 at 15:07
  • Yes, you can use [Facelets 1.x](http://facelets.java.net/nonav/docs/dev/docbook.html) (beware this tutorial is outdated and might contain broken links!). But composite components are introduced in Facelets 2.0 and not available in Facelets 1.x, so you can't use it in JSF 1.2 anyway. A tag file is really the best what you can get in JSF 1.2. – BalusC Oct 02 '12 at 15:08