我使用優秀的庫Primefaces,但不幸的是我不得不創建自己的組件來定製它。如何強制渲染使用jQuery和jqPlot庫的JSF複合組件
問題是組件顯示在第一個選項卡上,但不是第二個。
如何在加載標籤時強制顯示組件?
這裏的自定義組件WM:dateLineChart:
<?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">
<!-- INTERFACE -->
<cc:interface>
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<h:panelGroup rendered="true">
<div id="#{cc.id}"
style="height:208px;"/>
<script type="text/javascript" >
var chartId = '<h:outputText value="#{cc.id}"/>';
dateLineChart(chartId);
function dateLineChart(id) {
$(document).ready(function(){
jQuery.jqplot (id, [[3,7,9,1,4,6,8,2,5]], {
title: 'Plot With Options',
axesDefaults: {
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
},
axes: {
xaxis: {
label: "X Axis",
pad: 0
},
yaxis: {
label: "Y Axis"
}
}
});
});
}
</script>
</h:panelGroup>
</cc:implementation>
</html>
在這裏,在這裏我使用它:
<p:tabView id="tabView" dynamic="true" cache="true">
<p:tab id="homeView">
<wm:dateLineChart id="chartOnFirstTab" />
</p:tab>
<p:tab id="otherView" >
<wm:dateLineChart id="chartOnSecondTab" />
</p:tab>
</p:tabView>
請多關照您的幫助。
謝謝你,你的解決方案完美的作品,這個想法是切換標籤時發動重繪。由於我使用Primefaces,所以我會發佈一個適合的解決方案。 – momsse