Java ee6 > packages JSF facelets (XHTML) and managedbeans into jars
Can JSF facelets and managedbeans be packaged into jar files? So can we use this code and UI combination in different war / ear projects?
I'm not talking about JSF components!
If yes – you can point to a tutorial or blog post
Do I need details about the jar structure and other files required in jar?
Thank you, max
Solution
Yes, this is absolutely possible. Suppose you use JSF 2.0, part of Java EE 6
For managed beans and other JSF classes (such as validators, converters, etc.), just annotate them with @ managedbean, @ facesvalidator, @ facesconverter, etc., and package them in jars in the usual way All you need to do is provide a JSF 2.0 compliant / meta inf / faces config. XML in the jar XML file
<?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> </faces-config>
In this way, JSF will be triggered to scan JSF specific annotation classes in the jar Alternatively, you can use the jar's faces - config Register them in XML, JSF 1 X mode
For facelets resources, simply place them in the / meta - inf / Resources folder of the jar It will be treated in the same way as the public web content of war
You can also see:
> Packaging Facelets files (templates,includes,composites) in a JAR