简体   繁体   中英

How does JSF tags affect JSP lifecycle methods? What about JSP and facelets?

Do JSP lifecycle methods run when using JSF tags in JSP pages? If so, what is the sequence?

Do JSP lifecycle methods run when using facelets?

There's a very clarifying article on the subject in IBM's DeveloperWorks . On the subjetc of using JSP's in JSF applications it says the following:

The body of the JSP becomes the equivalent of a servlet's doGet() and doPost() methods (that is, it becomes the jspService() method). The JSF custom tags (such as f:view and h:form) are just calls to the JSF components to render themselves in their current state. The life cycle of the JSF component model is independent from the life cycle of the JSP-produced servlet.

So, the answer to your first question is yes; JSP pages follow their own lifecycle and JSF Components follow their own. On Facelets, you can also find this:

Unlike JSP, Facelets is a templating language built from the ground up with the JSF component life cycle in mind. With Facelets, you produce templates that build a component tree, not a servlet.

With that, there's no need of using JSP's with JSF if you're already using Facelets. So the answer to your second question would be no, as there are no JSP pages at all.

The JSP lifecycle methods (whatever those are) do not run when using JSF with Facelets, for the simple reason that Facelets is 100% separate from JSP.

You should btw never use JSF with JSP. It's a deprecated VDL for JSF, doesn't support the latest JSF features, and is just wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM