Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facelets without JSF

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?

like image 973
Der Avatar asked Jul 19 '12 20:07

Der


1 Answers

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.

like image 94
BalusC Avatar answered Sep 28 '22 06:09

BalusC