JAR问题中的复合组件与cc.attrs

时间:2011-11-29 21:46:32

标签: netbeans maven jsf-2 jar composite-component

对于我在JAR中打包的复合组件,我使用了<cc:interface>一个简单的<cc:attribute>,当然还有一个<cc:implementation>

在开发阶段,我有一个javax.faces.view.facelets.TagException抱怨cc:interface组件未检测到标识符«j_idt6.getParent()»。在生产阶段,它似乎有效,但<cc:attribute>的值没有按预期显示。

我在网上看到过JIRA问题JAVASERVERFACES-1903,但似乎有点旧。有没有人知道如何解决它?你认为这个问题有一天会得到解决吗?您如何使用项目处理JAR文件中的复合组件?

我的配置是Glassfish 3.1下的Mojarra 2.1.4。


从OP帖子更新,如下:

这是错误:

/file:/D:/Users/simplicity2k/Documents/NetBeansProjects/tmp/application/application-ear/target/gfdeploy/org.simplicity2k_application-ear_ear_1.0-SNAPSHOT/application-web-1.0-SNAPSHOT_war/WEB-INF/lib/components-1.0-SNAPSHOT.jar!/META-INF/resources/components/sampleOutput.xhtml @8,23 <cc:interface> Composant non détecté pour l’identificateur «j_idt6.getParent()».

堆栈跟踪:

javax.faces.view.facelets.TagException: /file:/D:/Users/simplicity2k/Documents/NetBeansProjects/tmp/application/application-ear/target/gfdeploy/org.simplicity2k_application-ear_ear_1.0-SNAPSHOT/application-web-1.0-SNAPSHOT_war/WEB-INF/lib/components-1.0-SNAPSHOT.jar!/META-INF/resources/components/sampleOutput.xhtml @8,23 <cc:interface> Composant non détecté pour l’identificateur «j_idt6.getParent()».
at com.sun.faces.facelets.tag.composite.InterfaceHandler.validateComponent(InterfaceHandler.java:135)
at com.sun.faces.facelets.tag.composite.InterfaceHandler.apply(InterfaceHandler.java:125)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:326)
at com.sun.faces.facelets.tag.UserTagHandler.apply(UserTagHandler.java:142)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:769)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)

我的JAR中的文件:

META-INF /资源/组件/ sampleOutput.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:cc="http://java.sun.com/jsf/composite">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="colorRed" default="F00" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:panelGroup layout="block" styleClass="componentContainer" style="border:1px solid \##{cc.attrs.colorRed};">
            <h:outputText value="Sample Output Component #{cc.attrs.colorRed}" />
        </h:panelGroup>
    </cc:implementation>

</html>

META-INF / components.taglib.xml

<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:composite="http://java.sun.com/jsf/composite"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
              version="2.0">

    <namespace>http://simplicity2k.org/components</namespace>
    <composite-library-name>components</composite-library-name>
    <tag>
        <tag-name>sampleOutput</tag-name>
        <source>resources/components/sampleOutput.xhtml</source>
    </tag>

</facelet-taglib>

2 个答案:

答案 0 :(得分:1)

您根本不需要taglib.xml文件。删除它并通过以下命名空间引用视图中的复合:

xmlns:ec="http://java.sun.com/jsf/composite/components"

“/ components”部分指的是资源文件夹中的文件夹“/ components”。

另见:

答案 1 :(得分:0)

好的解决了。错误在名称空间中,并使用cc:xxx而不是composite:xxx

    <?xml version="1.0"?>
    <facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:composite="http://java.sun.com/jsf/composite"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
                  version="2.0">

        <namespace>http://java.sun.com/jsf/composite</namespace>

        <tag>
            <tag-name>sampleExternalComponent</tag-name>
            <source>resources/ec/sampleExternalComponent.xhtml</source>
        </tag>

    </facelet-taglib>

组件:

<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <ui:composition>
        <!-- INTERFACE -->
        <composite:interface>
            <composite:attribute name="color" default="000000" required="false" />
        </composite:interface>

        <!-- IMPLEMENTATION -->
        <composite:implementation>
            <h:outputText value="#{sampleExternalComponentBean} || #{sampleExternalComponentBean.name} || #{cc.id} || #{cc.attrs.color}" style="color: \##{cc.attrs.color};" />
        </composite:implementation>
    </ui:composition>
</html>

并在WAR中调用它:xmlns:ec="http://java.sun.com/jsf/composite/ec"<ec:sampleExternalComponent id="ext" color="00F" />

问候