JSF 2.0复合组件进入jar [英] JSF 2.0 composite component into jar

查看:115
本文介绍了JSF 2.0复合组件进入jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个复合组件,以便在我的项目中使用,因此,我创建了一个名为componentes-ui-web的项目,并推出了2个xhtml文件,这些文件是我的组件。

I'm trying create a composite component to use across my projects, so, I've created a project called "componentes-ui-web" and putted 2 xhtml files that are my components.

项目结构如下:

src
> |-> main
> >       |->java
> >          |->META-INF
> >              |->faces-config.xml
> >              |->resources
> >                    |->componentes
> >                           |->popupSimples.xhtml
> >                           |->popupSubmit.xhtml

这是的代码popupSubmit.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:icecore="http://www.icefaces.org/icefaces/core"
        xmlns:ice="http://www.icesoft.com/icefaces/component"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:composite="http://java.sun.com/jsf/composite"
        xmlns:ace="http://www.icefaces.org/icefaces/components">
    <composite:interface>
        <composite:attribute name="modal" default="false" />
        <composite:attribute name="visivel" default="false" />
        <composite:attribute name="style" default="" />
        <composite:attribute name="titulo" default="Sem título definido" />
        <composite:attribute name="exibidoQuandoTipoUsuario" default="" />
        <composite:attribute name="metodoFechar"
        method-signature="java.lang.Void fechar()" required="true" />
        <composite:attribute name="metodoSubmeter"
        method-signature="java.lang.Void submeter()" required="true" />
        <composite:facet name="conteudo" />
    </composite:interface>
    <composite:implementation>
        <h:form>
            <ice:panelPopup modal="#{cc.attrs.modal}"
                    renderedOnUserRole="#{cc.attrs.exibidoQuandoTipoUsuario}"
                    draggable="#{cc.attrs.modal}" rendered="#{cc.attrs.visivel}"
                    clientOnly="true" autoCentre="true" style="#{cc.attrs.style}">
                <f:facet name="header">
                    <ui:insert name="barraDeTitulos">
                        <ice:panelLayout layout="flow" style="width:100%">
                            <h:outputText value="#{cc.attrs.titulo}" style="float:left" />
                            <h:commandLink value="[X]" style="float:right"
                                action="#{cc.attrs.metodoFechar}" immediate="true" />
                        </ice:panelLayout>
                    </ui:insert>
                </f:facet>
                <f:facet name="body">
                    <ice:panelLayout layout="flow" style="width:100%">              
                        <composite:renderFacet name="conteudo" />
                        <ui:insert name="barraDeBotoes">
                            <ice:panelLayout layout="flow">
                                <ace:pushButton value="CANCELAR" immediate="true"
                                    style="float:right" action="#{cc.attrs.metodoFechar}" />
                                <ace:pushButton value="OK" style="float:right"
                                    action="#{cc.attrs.metodoSubmeter}" />
                            </ice:panelLayout>
                        </ui:insert>
                    </ice:panelLayout>
                </f:facet>
            </ice:panelPopup>
        </h:form>
    </composite:implementation>
</html>

在另一个Web项目中,我尝试使用这个组件,只需将jar添加到lib(maven)和添加标签:

In another Web project I try to use this component simply adding that jar to the lib (maven) and adding the tag:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:hrgi="http://java.sun.com/jsf/composite/componentes"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<ui:component>
    <f:loadBundle basename="com.hrgi.web.configuracoes.messages"
    var="configuracoesMsg" />   
        <hrgi:popupSubmit modal="true" visivel="true"
    titulo="#{configuracoesMsg['popup.importador_nfe.titulo']}"
    exibidoQuandoTipoUsuario="ROLE_ADMINISTRADOR"
    metodoFechar="#{controladorPopupConfiguracaoImportadorNFe.fechar}"
    metodoSubmeter="#{controladorPopupConfiguracaoImportadorNFe.submeter}">
    <f:facet name="conteudo">
          ...
    </hrgi:popupSubmit>
</ui:component>
</html>

当我运行应用程序时,组件未显示,我在firefox中收到此消息:

When I run the application, the component isn't shown and I receive this message in the firefox:


警告:此页面调用XML命名空间 http://java.sun.com/jsf/composite/componentes 但该命名空间不存在taglibrary。

Warning: This page calls for XML namespace http://java.sun.com/jsf/composite/componentes declared with prefix hrgi but no taglibrary exists for that namespace.

我做错了什么?

更新感谢回复,感谢很晚才回复...

Update thanks for the replies and sorry for the late to answer...

我创建了像BalusC一样的ResourceResolver告诉,但没有成功。
我也检查了tomcat的输出,但没有发现任何错误。

I've created the ResourceResolver like BalusC told, but without success. I've checked the output of tomcat too, but didn't find any error.

这是我的 web.xml 文件,也许有人可以找到任何可以帮助我的东西。
我也会搜索ResourceHandler。

This is my web.xml file, perhaps someone can find anything that could help me. I will search about ResourceHandler too.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        version="3.0">
    <display-name>teste-zk</display-name>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>/icefaces/*</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
        <param-value>com.hrgi.web.ui.FaceletsResourceResolver</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.enableMissingResourceLibraryDetection</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>false</param-value>
    </context-param>    
    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/xmlhttp/*</url-pattern>
    </servlet-mapping>
</web-app>


推荐答案

我已经解决了这个问题。我查看了jar文件,没有看到带有xhtml文件的META-INF / resources文件夹。所以我将META-INF文件夹从src / main / java更改为src / main / resources。它工作

I've solved the problem. I've looked inside the jar file and didn't see the META-INF/resources folder with the xhtml files. So I changed the META-INF folder from src/main/java to src/main/resources. It worked

这篇关于JSF 2.0复合组件进入jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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