2016-06-11 23 views
1

我產生與javascript中的圖像,並顯示結果的模式,但模式的圖像葉子:http://s2.subirimagenes.com/imagen/9603018modal.png如何在模態中顯示primefaces圖表?

這是我的代碼:

XHTML

<h:form id = "form1"> 
    <p:chart widgetVar="chart" style="width:1200px;height:400px" type = "bar" model="#{graphicBean.barModel}" rendered="#{not empty graphicBean.barModel}"/> 
    <p:commandButton onclick ="exportChart()" value = "Execute"/> 
    <b:commandButton class="btn btn-primary" value="Show" ajax="true" oncomplete="$('.modalGraphic').modal();return false;" /> 
</h:form> 

<b:modal id="id_modalGraphic" styleClass="modalGraphic" title="Guarda el gráfico"> 
    <h:form id = "resultado"> 
     <h:panelGroup id="output" layout="block" style="width:100px;height:100px"></h:panelGroup> 
    </h:form> 
</b:modal> 

的JavaScript

function exportChart() { 
    $('#resultado\\:output').empty().append(PF('chart').exportAsImage()); 
} 

我想要一張帶有卷軸的短圖片或原始大小的圖片。

謝謝!

+0

也許模態有一定的溢出CSS來顯示的東西,而不是滾動?圖像是否在模態中的正確位置? – Kukeltje

回答

0

我想你可以試試這個方法:

<p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" /> 

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100"> 

    here goes what you want to show in the modal 

</p:dialog> 

這是使用primefaces

+0

這就是OP正在做的事情。 outputPanel在對話框中。並且OP想要將圖表從圖表附加到它(導出的圖像),這就是jQuery部分正在做的事情。 – Kukeltje