2016-11-22 73 views
0

我是JSF的新手,我想在我的jsf页面中添加一个高图表,但我暗示了演示代码,当我运行它时,它会抛出我这个.. 。如何在JSF中实现量表实体图表

Error Parsing /index.xhtml: Error Traced[line: 185] El nombre de la entidad debe aparecer inmediatamente después de '&' en la referencia de entidades. 
javax.faces.view.facelets.FaceletException: Error Parsing /index.xhtml: Error Traced[line: 185] El nombre de la entidad debe aparecer inmediatamente después de '&' en la referencia de entidades. 

这是该指数

<?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:h="http://xmlns.jcp.org/jsf/html"> 
    <h:head> 
     <title>Facelet Title</title> 
    </h:head> 
    <h:body> 
     <script src="https://code.highcharts.com/highcharts.js"></script> 
     <script src="https://code.highcharts.com/highcharts-more.js"></script> 

     <script src="https://code.highcharts.com/modules/solid-gauge.js"></script> 

     <div style="width: 600px; height: 400px; margin: 0 auto"> 
      <div id="container-speed" style="width: 300px; height: 200px; float: left"></div> 
      <div id="container-rpm" style="width: 300px; height: 200px; float: left"></div> 
     </div> 
     <script type="text/javascript"> 
      $(function() { 

       var gaugeOptions = { 

        chart: { 
         type: 'solidgauge' 
        }, 

        title: null, 

        pane: { 
         center: ['50%', '85%'], 
         size: '140%', 
         startAngle: -90, 
         endAngle: 90, 
         background: { 
          backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE', 
          innerRadius: '60%', 
          outerRadius: '100%', 
          shape: 'arc' 
         } 
        }, 

        tooltip: { 
         enabled: false 
        }, 

        // the value axis 
        yAxis: { 
         stops: [ 
          [0.1, '#55BF3B'], // green 
          [0.5, '#DDDF0D'], // yellow 
          [0.9, '#DF5353'] // red 
         ], 
         lineWidth: 0, 
         minorTickInterval: null, 
         tickAmount: 2, 
         title: { 
          y: -70 
         }, 
         labels: { 
          y: 16 
         } 
        }, 

        plotOptions: { 
         solidgauge: { 
          dataLabels: { 
           y: 5, 
           borderWidth: 0, 
           useHTML: true 
          } 
         } 
        } 
       }; 

       // The speed gauge 
       var chartSpeed = Highcharts.chart('container-speed', Highcharts.merge(gaugeOptions, { 
        yAxis: { 
         min: 0, 
         max: 200, 
         title: { 
          text: 'Speed' 
         } 
        }, 

        credits: { 
         enabled: false 
        }, 

        series: [{ 
         name: 'Speed', 
         data: [80], 
         dataLabels: { 
          format: '<div style="text-align:center"><span style="font-size:25px;color:' + 
           ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' + 
            '<span style="font-size:12px;color:silver">km/h</span></div>' 
         }, 
         tooltip: { 
          valueSuffix: ' km/h' 
         } 
        }] 

       })); 

       // The RPM gauge 
       var chartRpm = Highcharts.chart('container-rpm', Highcharts.merge(gaugeOptions, { 
        yAxis: { 
         min: 0, 
         max: 5, 
         title: { 
          text: 'RPM' 
         } 
        }, 

        series: [{ 
         name: 'RPM', 
         data: [1], 
         dataLabels: { 
          format: '<div style="text-align:center"><span style="font-size:25px;color:' + 
           ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' + 
            '<span style="font-size:12px;color:silver">* 1000/min</span></div>' 
         }, 
         tooltip: { 
          valueSuffix: ' revolutions/min' 
         } 
        }] 

       })); 

       // Bring life to the dials 
       setInterval(function() { 
        // Speed 
        var point, 
         newVal, 
         inc; 

        if (chartSpeed) { 
         point = chartSpeed.series[0].points[0]; 
         inc = Math.round((Math.random() - 0.5) * 100); 
         newVal = point.y + inc; 

         if (newVal < 0 || newVal > 200) { 
          newVal = point.y - inc; 
         } 

         point.update(newVal); 
        } 

        // RPM 
        if (chartRpm) { 
         point = chartRpm.series[0].points[0]; 
         inc = Math.random() - 0.5; 
         newVal = point.y + inc; 

         if (newVal < 0 || newVal > 5) { 
          newVal = point.y - inc; 
         } 

         point.update(newVal); 
        } 
       }, 2000); 


      }); 
     </script> 
    </h:body> 
</html> 

我不知道我在做什么错误的代码,希望有人能帮助我使用的Facelets

+0

发表在谷歌你的错误:https://www.google.nl/search?q=El+nombre+de+la+entidad + debe + aparecer + inmediatamente + despu%C3%A9s + de +%27%26%27 + en + la + referencia + de + entidades,并看看它给出的行号(发布英文错误会给你更多的结果。我为此总是建议运行英文jdk) – Kukeltje

+2

[为什么&符号(&)需要在JSF中编码?有没有办法解决这个问题?](http://stackoverflow.com/questions/11086709/why-do-ampersands-need-to-be-encoded-in-jsf-is-there-a-way-around-this ) – Kukeltje

回答

0

JSF是基于XML所以在Java和大多数编程语言中,(&)将被视为实体而不是conditional operator。所以如果你想用你的facelets你必须改变所有&与&amp;这是&符实体。

+1

正如可以在重复中找到:http://stackoverflow.com/questions/11086709/why-do-ampersands-need-to-be-encoded-in-jsf-is-there-a-way-around-这在StackOverflow中是一个很好的练习来搜索这些并标记问题。保持这样'干净' – Kukeltje

0

此问题是由于未使用CData引起的。您应该使用CDATA这个

//<![CDATA[ 
    //javascript code 
//]]> 

什么呢意味着CDATA What does <![CDATA[]]> in XML mean?

+1

正如可以在重复中找到:http://stackoverflow.com/questions/11086709/why-do-ampersands-need-to-be-encoded-in-jsf-is-therea-a-方式围绕头这一点。在StackOverflow中搜索并标记问题是一种很好的做法。保持这样'干净' – Kukeltje

+0

你是对的,这解决了那个错误问题,现在我不知道为什么它不会在屏幕上显示任何东西,你认为我错过了什么? – Oscnicvaz