我想創建一個複合組件用於我的項目,所以,我創建了一個名爲「componentes-ui-web」的項目,並提出了2個xhtml文件,這是我的組件。JSF 2.0複合組件到罐子
項目的結構是這樣的:
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項目中,我嘗試使用這個組件簡單地添加罐子到lib(maven)並添加標籤:
<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>
當我運行應用程序時,c omponent不顯示我在Firefox中收到此消息:
警告:本網頁呼籲與前綴hrgi聲明XML命名空間http://java.sun.com/jsf/composite/componentes,但沒有標記庫存在該命名空間。
我做錯了什麼?
更新感謝您的答覆,併爲已故答覆對不起...
我創建了ResourceResolver像BalusC告訴,但沒有成功。 我也檢查了tomcat的輸出,但沒有發現任何錯誤。
這是我的web.xml
文件,也許有人可以找到任何可以幫助我的東西。 我也會搜索ResourceHandler。
<?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>
對不起,我的資源解析器答案是完全錯誤的。它確實不適用於複合材料。然而,我想知道爲什麼它適用於我們目前的項目中的複合材料。它們沒有在任何taglib xml文件中聲明。它們只是放在JAR的'/ META-INF/resources'文件夾中(另一個重要的文件是/ META-INF/faces-config.xml),它應該符合JSF2標準。 JAR構建器將它們包含在具體的JAR文件中?您可以使用zip工具提取JAR來驗證它。 – BalusC