我想在jboss縫2項目中使用谷歌可視化API。谷歌可視化+ jboss縫2
我已經創建了一個簡單的例子,它實際上取自Google Quick Start page。
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
當我在網絡瀏覽器中打開它作爲文件時,它很好地工作。但是當我將它放到我的Jboss Seam 2項目中並在網絡瀏覽器中打開時,它會在紅色背景上生成一條錯誤消息「b [c]未定義」。
在這裏,我看到了什麼,當我在瀏覽器中打開網頁的源文件:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="/MCMS/a4j/g/3_3_3.Final/org/ajax4jsf/framework.pack.js" type="text/javascript"></script>
<script src="/MCMS/a4j/g/3_3_3.Final/org/richfaces/ui.pack.js" type="text/javascript"></script>
<link class="component" href="/MCMS/a4j/s/3_3_3.Final/org/richfaces/skin.xcss/DATB/eAGTKJ8eErp8hjQADcsDKg__" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>
正如你可以看到JBoss Seam的增加了一些其他腳本索馬里紅新月會的A4J。
a4j JavaScript可能與谷歌可視化api javascript衝突嗎?
是否有任何想法如何解決這個問題?
如果你刪除了谷歌代碼,只是添加了一些標準的HTML,它是否工作沒有錯誤? (也許是其他包裝中的錯誤?) – jmac
是的。它工作沒有谷歌代碼。其他軟件包中不會出現錯誤,因爲它已經是一個長期生活的項目,其中Jboss Seam(+豐富人臉)的所有功能都可以很好地工作。現在我們想用谷歌可視化來顯示一些圖表。 –
我還發現一個人在JSF webapp中有類似的問題https://groups.google.com/forum/#!topic/google-visualization-api/bRAXXqW06DA –