Facelets without JSF
Asked Answered
C

2

7

I'm finishing on learning the Java language and looking to write very small web applications, since Facelets seems to be the replacement for JSP, and JSF seems overkill for small web apps, can I just learn Facelets and use it without the whole JSF stack? or should I just go with JSP for this small web apps?

Crockett answered 19/7, 2012 at 20:50 Comment(2)
Would you like to read this and this questions?Lakin
I read those but they don't really say if facelets can be use as a standalone technology.Crockett
I
6

It can be used without JSF. Just map the FacesServlet on an URL pattern of *.xhtml in web.xml and do not declare

xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"

in any Facelet template. It actually don't harm to declare them, but this way you won't "accidentally" use them. You can as good write plain HTML in it and submit the form to a plain servlet and have the servlet forward/redirect to a Facelet.

You only need to keep in mind that with a servlet you end up with much more boilerplate code for gathering the request parameters, converting/validating them, maintaining and updating the model values, invoking the business actions, while all this repeated boilerplate code is unnecessary with a fullworthy JSF managed bean.

Also, you can't use Facelets with request based MVC frameworks which have only JSP taglibs available, like Struts, Spring MVC, etc.

Iambic answered 20/7, 2012 at 15:2 Comment(3)
Well you still need the whole jsf jar isn't it? Also, when f: and h: is not used, what templating options are left to the developer? Isn't ui considered as a part of jsf for example?Vereen
Why did you say do not declare xmlns:f and :h only? And what can you do without using these tags in a facelets page? Only el is available then?Vereen
No I mean why did not you say "do not declare ui:" as well? Why did you say do not declare f: and h: only?Vereen
T
0

Facelets is developed for the need of JSF and as so is dependent on JSF. If you need templating for JSP simply use <@import>, or more advanced library as Apache Tiles.

Tinner answered 20/7, 2012 at 14:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.