使用Netbeans 7.0.1,Maven在JSF2中打包复合组件 [英] Packaging composite component in JSF2 with Netbeans 7.0.1, Maven

查看:108
本文介绍了使用Netbeans 7.0.1,Maven在JSF2中打包复合组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上阅读了很多关于在JAR文件中打包JSF2复合组件的内容。

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

有人知道我在哪里可以找到必须是什么JAR的结构(规范,官方文档等)。有没有办法用Netbeans IDE做,或者Maven是否存在原型?

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 ?

推荐答案

来自JSF 复合标签库文档摘要(强调我的):

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


创建复合组件



默认实现必须支持创作。通过在资源库中创建Facelets2文件来声明复合组件。 (有关资源库的更多信息,请参阅规范起草文档的JSF.2.6部分。)复合组件必须位于资源库中。如果不将它放在资源库中,就无法创建复合组件。

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.

来自 JSF规范


2.6.1.2将资源打包到类路径中



对于默认实现,类路径中打包的资源必须位于
JAR条目名称下:

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>

必须使用 getResource *()<访问打包到类路径中的资源/ code>通过调用当前<$ c的 getContextClassLoader()方法获得的 ClassLoader 的方法$ c>线程

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.

到目前为止,所有复合组件必须进入 / META-INF / resources JAR的文件夹。在常规WAR中,它与 / WEB-INF / resources 的处理方式相同(因此您仍需要一个额外的子文件夹来表示复合组件的主命名空间)。

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).

对于这种情况,如果JAR还包含带有 @ManagedBean 等JSF注释的类,那么JAR必须还有一个JSF 2.0兼容的 /META-INF/faces-config.xml 文件,以便触发JSF注释扫描程序为实现任何JSF的类抓取整个JAR注释。

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.

对于Netbeans / Maven部分,抱歉我不知道因为我不使用它们。

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

这篇关于使用Netbeans 7.0.1,Maven在JSF2中打包复合组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆