IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JSF Java Discussion :

[Primefaces] Export/Imprimer un chart


Sujet :

JSF Java

  1. #1
    Membre actif
    Homme Profil pro
    Développeur Java
    Inscrit en
    Février 2007
    Messages
    108
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Territoire de Belfort (Franche Comté)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2007
    Messages : 108
    Points : 255
    Points
    255
    Par défaut [Primefaces] Export/Imprimer un chart
    Bonjour,

    J'ai un chart que j'ai réaliser avec JSF 5.2 et j'aimerais pouvoir imprimer celui-ci avec un click sur un bouton.
    Voici mon code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
     
    <!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:ui="http://java.sun.com/jsf/facelets"
    	xmlns:h="http://java.sun.com/jsf/html"
    	xmlns:f="http://java.sun.com/jsf/core"
    	xmlns:p="http://primefaces.org/ui">
     
    <ui:composition>
     
    	<h:outputStylesheet library="css" name="style.css" />
     
    	<script type="text/javascript">
    		function exportChart() {
    			document.getElementById('outputChart').empty().append(
    					PF('chart').exportAsImage());
     
    			//show the dialog
    			PF('dlg').show();
    		}
    	</script>
     
     
     
    	<p:dialog widgetVar="dlg" showEffect="fade" modal="true"
    		header="Chart as an Image">
    		<p:outputPanel id="outputChart" layout="block"
    			style="width:500px;height:300px" />
    	</p:dialog>
     
     
     
    	<p:panelGrid columns="2" border="1">
    		<p:panelGrid columns="1" border="0">
    			<p:commandButton value="Print" type="button" icon="ui-icon-print"
    				onclick="exportChart()" />
     
    			<p:chart widgetVar="chart" type="line"
    				model="#{curves1.lineModel}"
    				style="height:800px;width:800px;" />
    		</p:panelGrid>
     
    		<p:chart type="line" model="#{curves2.lineModel}"
    			style="height:800px;width:800px;" />
     
    	</p:panelGrid>
    </ui:composition>
     
    </html>
    Avez-vous une solution pour imprimer un chart svp ?

    Merci d'avance

  2. #2
    Membre averti Avatar de Doopeijii
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2012
    Messages
    215
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Orne (Basse Normandie)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2012
    Messages : 215
    Points : 323
    Points
    323
    Par défaut
    Je ne connais pas PrimeFaces (enfin pas encore !) mais la solution ne semble pas très loin :

    http://lmgtfy.com/?q=primefaces+p%3Aprinter

    J'te laisse approfondir toi-même mais j'pense que ça devrai t'aider ;-)

  3. #3
    Membre actif
    Homme Profil pro
    Développeur Java
    Inscrit en
    Février 2007
    Messages
    108
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Territoire de Belfort (Franche Comté)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2007
    Messages : 108
    Points : 255
    Points
    255
    Par défaut
    Merci

    Alors, en fait ma dialog etant contenu dans un form, il faut le preciser dans la methode JS...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <script type="text/javascript">
    			function exportChart() {
    				//export image
    				$('#formId\\:output').empty().append(PF('chart').exportAsImage());
     
    				//show the dialog
    				PF('dlg').show();
    			}
    		</script>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. imprimer microsoft chart
    Par ayarikhaoulakoukou dans le forum VB.NET
    Réponses: 0
    Dernier message: 30/03/2011, 16h47
  2. imprimer microsoft chart
    Par ayarikhaoulakoukou dans le forum VB.NET
    Réponses: 0
    Dernier message: 21/03/2011, 14h11
  3. Imprimer un chart & stringgrid
    Par byakuichi dans le forum Débuter
    Réponses: 0
    Dernier message: 05/09/2010, 14h39
  4. exporter / imprimer l'image d'une frame
    Par genevieve.charbon dans le forum ActionScript 3
    Réponses: 0
    Dernier message: 03/02/2008, 19h24
  5. Exporter/imprimer la structure d'une table
    Par rudib dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 30/04/2007, 16h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo