2014-03-13 49 views
0

我有一個文件Chart.xhtml如下找不到組件標識符在JSF

<?xml version='1.0' encoding='UTF-8' ?> 
<!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:cc="http://java.sun.com/jsf/composite" 
    xmlns:h="http://java.sun.com/jsf/html" > 

<cc:interface> 
    <cc:attribute name="title" /> 
    <cc:attribute name="subTitle" /> 
    <cc:attribute name="yLabel" /> 
    <cc:attribute name="xLabel" /> 
    <cc:attribute name="xMinTickInterval" /> 
</cc:interface> 

<cc:implementation> 
    <h:outputScript name="javascript/highcharts/js/highcharts.js" target="head" /> 

    <div id="#{cc.id}_chartDiv"/> 

    <script type="text/javascript">    
     $(function() { 
      // Data must be defined WITHIN the function. This prevents 
      // different charts using the same data variables. 
      var options = { 
       credits: { 
        enabled: false 
       }, 
       chart: { 
        renderTo: '#{cc.id}_chartDiv', 
        zoomType: 'x', 
        width: 720 
        //margin: [50, 50, 100, 80] 
       }, 
       title: { 
        text: '#{cc.attrs.title}' 
       }, 
       subtitle: { 
        text: '#{cc.attrs.subTitle}' 
       }, 
       xAxis: { 
        title: { 
         enabled: true, 
         text: '#{cc.attrs.xLabel}' 
        }, 
        minTickInterval: '#{cc.attrs.xMinTickInterval}' 
       }, 
       yAxis: { 
        title: { 
         text: '#{cc.attrs.yLabel}' 
        } 
       }, 
       legend: { 
        enabled: false 
       } 
      }; 
      // Don't create the chart if there are no series defined. 
      if(typeof options.series !== "undefined") { 
       if(options.series.length > 1) { 
        options.legend.enabled = true; 
       } 
       var chart = new Highcharts.Chart(options); 
      } 
     }); 
    </script> 
</cc:implementation> 

以上xml是從

<hc:Chart title="New Zealand Nation Ethnic Population Estimates for 2006" xLabel="Age Groups (Years)" yLabel="Percentage of Total Population">

調用自定義標記這是包含庫聲明的文件

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
To change this template, choose Tools | Templates 
and open the template in the editor. 
--> 
<facelet-taglib version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"> 

<namespace>http://nz.co.kevindoran/highcharts-jsf</namespace> 
<tag> 
    <tag-name>Chart</tag-name> 
    <source>highcharts/Chart.xhtml</source> 
</tag> 
<tag> 
    <tag-name>ColumnSeries</tag-name> 
    <source>highcharts/ColumnSeries.xhtml</source> 
</tag> 
<tag> 
    <tag-name>CartesianSeries</tag-name> 
    <source>highcharts/CartesianSeries.xhtml</source> 
</tag> 
<tag> 
    <tag-name>ColumnOptions</tag-name> 
    <source>highcharts/ColumnOptions.xhtml</source> 
</tag> 
<tag> 
    <tag-name>TimeChart</tag-name> 
    <source>highcharts/TimeChart.xhtml</source> 
</tag> 
<tag> 
    <tag-name>TimeSeries</tag-name> 
    <source>highcharts/TimeSeries.xhtml</source> 
</tag> 
<tag> 
    <tag-name>TimeTrendChart</tag-name> 
    <source>highcharts/TimeTrendChart.xhtml</source> 
</tag> 
<tag> 
    <tag-name>Tooltip</tag-name> 
    <source>highcharts/Tooltip.xhtml</source> 
</tag> 
<composite-library-name>highcharts</composite-library-name> 

錯誤看起來像 /WEB-INF/highcharts/Chart.xhtml @7,19 <cc:interface> Component Not Found for identifier: j_idt8.getParent().

這究竟是爲什麼?

+0

如何聲明命名空間? – Leo

+0

是的,我更新了 –

+0

只是在這裏猜測,但你有沒有試過在['中包裝那個組合,如[wiki](http://stackoverflow.com/tags/composite-component/info)中所述)? – mabi

回答

0

您的實體類'Char'是否具有屬性'parent'?

看起來你的實體確實有一個'Parent'屬性,但是你沒有在「cc:interface」標籤中引用它。

嘗試添加里面下面的 「CC:接口」 標籤:

CC:屬性名稱= 「父」

+0

沒有標記名稱爲「parent」,它的內容不同。 –