Packaging composite component in JSF2 with Netbeans 7.0.1, Maven

浪尽此生 提交于 2019-12-09 07:05:17

问题


I've read a lot of things on the Internet about packaging JSF2 composite component in a JAR file.

Does somebody know where I can find what MUST be the structure of JAR (specs, official doc, etc, ). Is there a way to do it with Netbeans IDE, or does an archetype exist for Maven ?


回答1:


From the JSF composite tag library documentation summary (emphasis mine):

Creating a Composite Component

The default implementation must support authoring. A composite component is declared by creating a Facelets2 file inside of a resource library. (See section JSF.2.6 of the specification prose document for more information about resource libraries.) A composite component must reside within a resource library. It is not possible to create a composite component without putting it inside of a resource library.

From section 2.6 of the JSF specification:

2.6.1.2 Packaging Resources into the Classpath

For the default implementation, resources packaged in the classpath must reside under the JAR entry name:

META-INF/resources/<resourceIdentifier>

Resources packaged into the classpath must be accessed using the getResource*() methods of the ClassLoader obtained by calling the getContextClassLoader() method of the current Thread.

To the point, all composite components must go into /META-INF/resources folder of the JAR. It's to be treated the same way as /WEB-INF/resources in the regular WAR (so you still need an extra subfolder to represent the composite compnent's main namespace).

For the case that, if the JAR also contains classes with JSF annotations like @ManagedBean and such, then the JAR must also have a JSF 2.0 compatible /META-INF/faces-config.xml file in order to trigger the JSF annotation scanner to crawl the entire JAR for classes implementing any of the JSF annotations.

As to the Netbeans/Maven part, sorry I have no idea as I don't use them.



来源:https://stackoverflow.com/questions/8295935/packaging-composite-component-in-jsf2-with-netbeans-7-0-1-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!