<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Everything is wrong &#187; XML</title>
	<atom:link href="http://everythingiswrong.free.fr/index.php/category/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://everythingiswrong.free.fr</link>
	<description>Un blog dédié à l&#039;informatique en général</description>
	<lastBuildDate>Wed, 06 Oct 2021 21:20:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Fiji 2.0 : Intégration de FusionCharts et JSF</title>
		<link>http://everythingiswrong.free.fr/index.php/2011/03/01/fiji-2-0-integration-de-fusioncharts-et-jsf/</link>
		<comments>http://everythingiswrong.free.fr/index.php/2011/03/01/fiji-2-0-integration-de-fusioncharts-et-jsf/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 10:42:53 +0000</pubDate>
		<dc:creator>Yan</dc:creator>
				<category><![CDATA[Java J2EE]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Fiji]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[FusionCharts]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSF]]></category>

		<guid isPermaLink="false">http://yan.langlois.free.fr/wordpress/?p=988</guid>
		<description><![CDATA[Intégration d'un graphique FusionCharts dans une page JSF grâce à Fiji.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Après avoir parlé de Fiji il y a quelques mois, j&#8217;ai souhaité développer un petit exemple pour mettre en pratique l&#8217;intégration Flex dans une page JSF 2. Pour cela j&#8217;ai choisis d&#8217;intégrer un graphique FusionCharts dans une page JSF. Pour information, FusionCharts est une librairie graphique qui permet de développer des graphiques à partir d&#8217;un fichier XML (lignes, histogrammes, cartes du monde, etc.).</p>
<h1 style="text-align: justify;">Mise en place du projet</h1>
<p style="text-align: justify;">Pour faire simple, j&#8217;ai choisis de commencer une nouvelle application Java J2EE6 grâce au squelette de projet weld : org.jboss.weld.archetypes:weld-jsf-servlet-minimal. Je suis ensuite aller chercher les librairies tierces suivantes :</p>
<ul>
<li>Fiji 2.0 sur le site <a href="http://exadel.org/fiji" target="_blank">http://exadel.org/fiji</a></li>
<li>FusionCharts sur le site <a href="http://www.fusioncharts.com/free/Overview.asp" target="_blank">http://www.fusioncharts.com/free/Overview.asp</a> (version gratuite)</li>
</ul>
<h1>Développement</h1>
<p>Mon but est de reproduire le premier exemple de graphique proposé sur la <a href="http://www.fusioncharts.com/free/gallery/" target="_blank">gallerie</a> du site internet de FusionCharts :</p>
<p style="text-align: center;"><img class="aligncenter" src="http://yan.langlois.free.fr/wordpress/wp-content/uploads/fusionChartsFijiExample.png" alt="" width="585" height="339" /></p>
<p>Tout d&#8217;abord, il faut déposer la librairie Fiji 2.0 dans le répertoire <em>src/main/webapp/WEB-INF/lib</em> puis un graphique fusionChart (*.swf) dans un répertoire web du projet. Ensuite, deux fichiers sont nécessaires :</p>
<ul>
<li>Un fichier XHTML pour générer le XML qui décrit le graphique</li>
<li>Un fichier XHTML pour  décrire la page JSF qui va intégrer le graphique</li>
</ul>
<p style="text-align: justify;">Voici le fichier XHTML qui va décrire le graphique :</p>
<pre class="brush: xml; toolbar: true;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;f:view 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" contentType="text/xml"&gt;

 &lt;graph yAxisName='Sales Figure' caption='Top 5 Sales Person' numberPrefix='$'
    decimalPrecision='1' divlinedecimalPrecision='0' limitsdecimalPrecision='0'&gt;
   &lt;ui:repeat var="item" value="#{dynaGraphique.listPersonne}"&gt;
      &lt;set name='#{item.name}' value='#{item.sales}' color='#{item.color}' /&gt;
   &lt;/ui:repeat&gt;
 &lt;/graph&gt;

&lt;/f:view&gt;</pre>
<p style="text-align: justify;">On peut remarquer que j&#8217;utilise le tag <em>&lt;ui:repeat/&gt;</em> pour itérer sur une liste de données qui va représenter plusieurs séries sur mon histogramme. Ci-dessous, le fichier qui décrit le même graphique en static :</p>
<pre class="brush: xml; toolbar: true;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;f:view 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" contentType="text/xml"&gt;

   &lt;graph yAxisName='Sales Figure' caption='Top 5 Sales Person' numberPrefix='$'
      decimalPrecision='1' divlinedecimalPrecision='0' limitsdecimalPrecision='0'&gt;
        &lt;set name='Alex' value='25000' color='AFD8F8' /&gt;
        &lt;set name='Mark' value='35000' color='F6BD0F' /&gt;
        &lt;set name='David' value='42300' color='8BBA00' /&gt;
        &lt;set name='Graham' value='35300' color='FF8E46' /&gt;
        &lt;set name='John' value='31300' color='008E8E' /&gt;
   &lt;/graph&gt;

&lt;/f:view&gt;</pre>
<p style="text-align: justify;">Les deux classes java qui vont contenir les données pour le graphique. Vous allez retrouver les données précédentes dans la première classe :</p>
<pre class="brush: java; toolbar: true;">@Model
public class DynaGraphique {
 private List&lt;Personne&gt; listPersonne = new ArrayList&lt;Personne&gt;();

 @PostConstruct
 public void initialize() {
   listPersonne.add(new Personne("Alex", 25000, "AFD8F8"));
   listPersonne.add(new Personne("Mark", 35000, "F6BD0F"));
   listPersonne.add(new Personne("David", 42300, "8BBA00"));
   listPersonne.add(new Personne("Graham", 35300, "FF8E46"));
   listPersonne.add(new Personne("John", 31300, "008E8E"));
 }
 // Getter et Setter

}</pre>
<pre class="brush: java; toolbar: true;">public class Personne {
 private String name;
 private int sales;
 private String color;

 public Personne() {
 }

 public Personne(String name, int sales, String color) {
 super();
 this.name = name;
 this.sales = sales;
 this.color = color;
 }
//Getter et Setter ...
...
}</pre>
<p style="text-align: justify;">Le fichier XHTML qui va générer la page JSF :</p>
<pre class="brush: xml; toolbar: true;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:fiji="http://exadel.com/fiji"
   template="/WEB-INF/templates/default.xhtml"
   xmlns:a4j="http://richfaces.org/a4j"&gt;
      &lt;ui:define name="content"&gt;
         &lt;!-- static : voir le fichier fusionChart/fusion01.jsf --&gt;
         &lt;fiji:swf src="fusionChart/FCF_Column3D.swf" bgcolor="#FFFFFF" width="520" height="400"&gt;
            &lt;f:param name="dataURL" value="fusionChart/fusion01.jsf" /&gt;
         &lt;/fiji:swf&gt;
         &lt;!-- dynamique --&gt;
         &lt;fiji:swf src="fusionChart/FCF_Column3D.swf" bgcolor="#FFFFFF" width="520" height="400"&gt;
            &lt;f:param name="dataURL" value="fusionChart/fusion02.jsf" /&gt;
         &lt;/fiji:swf&gt;
      &lt;/ui:define&gt;
&lt;/ui:composition&gt;</pre>
<p style="text-align: justify;">Pour information, il ne faut pas oublier de préciser les attributs <em>bgcolor</em>, <em>width </em>et <em>height </em>pour éviter une erreur d&#8217;exécution de Fiji.</p>
<h1>Exécution du projet</h1>
<p style="text-align: justify;">Pour exécuter le projet, j&#8217;utilise la commande maven <em>mvn compile tomcat:run.</em> L&#8217;application est alors disponible à l&#8217;adresse : <a href="http://localhost:9090/jsf.servlet.minimal" target="_blank">http://localhost:9090/jsf.servlet.minimal</a>.</p>
<p style="text-align: justify;">Vous pouvez checkouter le projet à l&#8217;adresse suivante : <a href="http://subversion.assembla.com/svn/everythingiswrong/tutorial-fiji-fusionchart/" target="_blank">http://subversion.assembla.com/svn/everythingiswrong/tutorial-fiji-fusionchart/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://everythingiswrong.free.fr/index.php/2011/03/01/fiji-2-0-integration-de-fusioncharts-et-jsf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jaxb2-maven-plugin : plusieurs exécutions successives de jaxb2:xjc</title>
		<link>http://everythingiswrong.free.fr/index.php/2011/02/11/jaxb2-maven-plugin-plusieurs-executions-successives-de-jaxb2xjc/</link>
		<comments>http://everythingiswrong.free.fr/index.php/2011/02/11/jaxb2-maven-plugin-plusieurs-executions-successives-de-jaxb2xjc/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 21:13:58 +0000</pubDate>
		<dc:creator>Yan</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Java J2EE]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://yan.langlois.free.fr/wordpress/?p=893</guid>
		<description><![CDATA[Configuration particulière du plugin jaxb2-maven-plugin]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Dans ce ticket, je vais expliquer comment bien configurer le plugin <a href="http://mojo.codehaus.org/jaxb2-maven-plugin/">jaxb2-maven-plugin</a> dans le cas où l&#8217;on souhaite transformer des fichiers XSD en classes java vers des packages différents. Il faut savoir qu&#8217;avec ce plugin il n&#8217;est pas possible de définir plusieurs packages de destination dans une même exécution.</p>
<p style="text-align: justify;">Dans l&#8217;exemple choisi, je génère deux classes Java à partir de deux fichier XSD vers deux packages différents :</p>
<p style="text-align: justify;">
<pre class="brush: xml; toolbar: true;">&lt;plugin&gt;
  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
  &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;id&gt;id1&lt;/id&gt;
      &lt;phase&gt;generate-sources&lt;/phase&gt;
      &lt;goals&gt;
        &lt;goal&gt;xjc&lt;/goal&gt;
      &lt;/goals&gt;
      &lt;configuration&gt;
        &lt;clearOutputDir&gt;false&lt;/clearOutputDir&gt;
        &lt;staleFile&gt;${project.build.directory}/generated-sources/jaxb/.staleFlag-id1&lt;/staleFile&gt;
        &lt;schemaDirectory&gt;${basedir}/src/main/resources/id1&lt;/schemaDirectory&gt;
        &lt;packageName&gt;id1&lt;/packageName&gt; &lt;!-- The name of your generated source package --&gt;
      &lt;/configuration&gt;
    &lt;/execution&gt;
    &lt;execution&gt;
      &lt;id&gt;id2&lt;/id&gt;
      &lt;phase&gt;generate-sources&lt;/phase&gt;
      &lt;goals&gt;
        &lt;goal&gt;xjc&lt;/goal&gt;
      &lt;/goals&gt;
      &lt;configuration&gt;
        &lt;clearOutputDir&gt;false&lt;/clearOutputDir&gt;
        &lt;staleFile&gt;${project.build.directory}/generated-sources/jaxb/.staleFlag-id2&lt;/staleFile&gt;
        &lt;schemaDirectory&gt;${basedir}/src/main/resources/id2&lt;/schemaDirectory&gt;
        &lt;packageName&gt;id2&lt;/packageName&gt; &lt;!-- The name of your generated source package --&gt;
      &lt;/configuration&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;dependencies&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;xerces&lt;/groupId&gt;
       &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
       &lt;version&gt;2.8.1&lt;/version&gt;
     &lt;/dependency&gt;
  &lt;/dependencies&gt;
&lt;/plugin&gt;</pre>
<p style="text-align: justify;">A noter que pour chaque exécution :</p>
<ul>
<li style="text-align: justify;">Il est nécessaire d&#8217;utiliser un identifiant unique. Sinon maven n&#8217;arrivera pas à exécuter le plugin.</li>
<li style="text-align: justify;">Il faut impérativement utiliser l&#8217;option staleFile pour associer un fichier différent à chaque exécution (ce fichier sert au plugin pour savoir si les classes Java sont déjà générées). Sans cela, la seconde exécution ne génèrera pas de classe Java.</li>
<li style="text-align: justify;">Il faut indiquer au plugin de ne pas nettoyer le répertoire de génération avant l&#8217;exécution (option clearOutputDir à false) car c&#8217;est son comportement par défaut. Sans cela, la seconde exécution supprimera les classes générées pas la première.</li>
</ul>
<p style="text-align: justify;">Voici l&#8217;adresse de l&#8217;exemple associé : <a href="https://subversion.assembla.com/svn/everythingiswrong/tutorial-jaxb2-maven-plugin/" target="_blank">https://subversion.assembla.com/svn/everythingiswrong/tutorial-jaxb2-maven-plugin/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://everythingiswrong.free.fr/index.php/2011/02/11/jaxb2-maven-plugin-plusieurs-executions-successives-de-jaxb2xjc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
