How to use Java facelets as a common template engine in stand-alone applications?

I want to use facelets to generate HTML content I want to reuse the existing taglibs, which is not supported by velocity

I have read the developer's guide, but I have no clue

Does facelets need a java compiler to work? (I guess not) I've tried jetty servlettester, but it doesn't seem to work

Is that possible?

Solution

Yes, it is possible

There is no need to use the java compiler to render the view Facelets is completely driven by taglib, and only el (expression language) may occur in the template script, so there is no need for static compilation

To embed facelets in a stand - alone application, you can programmatically initialize the servlet context I use jetty in this case View the implementation of the servlettester class and write your own server

It's worth mentioning that JSF RI doesn't work properly, but fortunately we have another option. We can use the better myfaces impl

The main problem remains resourceresolver If you need to set a complex resource structure, that is, the template file (XHTML) is placed in different locations, you need to:

>Create your own resourceresolver delegate defaultresourceresolver. > Coverage org mortbay. jetty. servlet. Context. Getresource () to return the consistent resource of resourceresolver Or similarly, if the embedded servlet context is not based on jetty

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>