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

Flex Discussion :

BlazeDS et transmission de type


Sujet :

Flex

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2010
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2010
    Messages : 26
    Par défaut BlazeDS et transmission de type
    Bonjour,

    J'ai récemment suivi ce tuto : <html>http://fponchel.developpez.com/tutoriel/flex3/integration/blazeds-spring/</html>
    et je suis parvenu jusqu'au bout. J'essaye maintenant d'appliquer cette méthode à mon appli, mais je rencontre quelques problèmes.

    Mon appli cliente Flex invite l'utilisateur à rentrer des info sur un livre dans le but de l'enregistrer en ePub.

    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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
     
    <mx:Script>
    		<![CDATA[
    			import mx.events.FlexEvent;
    			import mx.controls.Alert;
    			import mx.rpc.events.ResultEvent;
     
    			private function onResult(evt:ResultEvent):void
    			{
    				Alert.show("C'est bon !!!");
    			}
     
    			private function onFault(evt:Event):void
    			{
    				Alert.show("Erreur lors de l'enregistrement !");
    			}
     
    			private function enregistrer(evt:Event):void
    			{
    				var monLivre:Livre = new Livre();
    				var monChapitre:Chapitre = new Chapitre();
    				var maListePara:Array = new Array();
    				var maListeChap:Array = new Array();
     
    				monLivre.setTitre(titreLivre.text);
    				monLivre.setCreateur(auteurLivre.text);
    				monLivre.setLangue(cb.selectedItem.toString());
     
    				monChapitre.setTitre(titreChapitre.text);
    				maListePara.push(zoneChapitre.text);
    				monChapitre.setListeParagraphes(maListePara);
    				maListeChap.push(monChapitre);
     
    				monLivre.setListeChapitres(maListeChap);
     
    				roWriteEpub.enregistrerEpub("coucou23456");
    			}
     
    		]]>
    	</mx:Script>
    <mx:RemoteObject id="roWriteEpub" destination="writeEpubDest" result="onResult(event)" fault="onFault(event)"/>
    	<mx:Panel width="622" layout="absolute">
    		<mx:Label x="212.5" y="10" text="Test de création d'un Epub simple"/>
    	<mx:Label x="47" y="60" text="Titre : "/>
    	<mx:TextInput id="titreLivre" x="109" y="58" width="409.75"/>
    	<mx:Label x="36" y="90" text="Auteur : "/>
    	<mx:TextInput id="auteurLivre" x="109" y="88" width="409.75"/>
    	<mx:Label x="31" y="120" text="Langue : "/>
    	<mx:ComboBox id="cb" x="109" y="118" width="77">
    		<mx:ArrayCollection>
    			<mx:Object label="fr"/>
    			<mx:Object label="en"/>
    			<mx:Object label="es"/>
    		</mx:ArrayCollection>
    	</mx:ComboBox>
    	<mx:HRule x="31" y="148" width="379"/>
    	<mx:Label x="74" y="158" text="Titre du Chapitre : "/>
    	<mx:TextInput id="titreChapitre" x="209" y="156" width="309.75"/>
    	<mx:TextArea id="zoneChapitre" x="209" y="186" width="309.75" height="257"/>
    	<mx:Label x="25" y="187" text="Contenu (un paragraphe) : "/>
    	<mx:Button id="btnSave" x="370" y="470" label="Enregistrer" click="enregistrer(event)"/>
    	</mx:Panel>
    J'ai bien entendu créé mes deux types Livre et Chapitre. Dans cet exemple, le livre aura un titre, un auteur, une langue, un chapitre avec un paragraphe.

    J'appelle ensuite la méthode enregistrerEpub, en lui passant en paramètre le Livre. J'ai bien sur pris soin d'écrire les classes Livre et Chapitre en Java.

    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
    public class SaveLivre {
     
    	public void enregistrerEpub(Livre monLivre)
    	{
    		{
    			System.out.println("coucou");
    			Publication epub = new Publication();
     
    			epub.addDCMetadata("title", monLivre.getTitre());
    			epub.addDCMetadata("creator", monLivre.getCreateur());
    			epub.addDCMetadata("language", monLivre.getLangue());
     
    			 NCXResource toc = epub.getTOC();
    		     TOCEntry rootTOCEntry = toc.getRootTOCEntry();
     
    		     OPSResource main = epub.createOPSResource("OPS/main.html");
    		     epub.addToSpine(main);
     
    		     OPSDocument mainDoc = main.getDocument();
     
    		     ArrayList<Chapitre> listChap = new ArrayList<Chapitre>();
    		     ArrayList<String> listPara = new ArrayList<String>();
     
    		     listChap = monLivre.getListeChapitres();
    		     listPara = listChap.get(0).getListeParagraphes();
     
    		     TOCEntry mainTOCEntry = toc.createTOCEntry(listChap.get(0).getTitre(), mainDoc.getRootXRef());
    		     rootTOCEntry.add(mainTOCEntry);
     
    		     Element body = mainDoc.getBody();
     
    		     Element h1 = mainDoc.createElement("h1");
    		     h1.add(listChap.get(0).getTitre());
    		     body.add(h1);
     
    		     Element paragraph = mainDoc.createElement("p");
    		     paragraph.add(listPara.get(0));
    		     body.add(paragraph);
     
    		     OCFContainerWriter writer = new OCFContainerWriter(
    		             new FileOutputStream("hello.epub"));
    		         epub.serialize(writer);
     
    		}catch (Exception e) {
    		      e.printStackTrace();
    	    }
    	}
    }
    Je rencontre alors un problème : on m'indique que :

    [BlazeDS]Error instantiating application scoped instance of type 'com.service.SaveLivre' for destination 'writeEpubDest'.

    Voici mon remoting-config.xml :

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <service id="remoting-service" 
        class="flex.messaging.services.RemotingService">
     
        <adapters>
            <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
        </adapters>
     
        <default-channels>
            <channel ref="my-amf"/>
        </default-channels>
     
        <destination id="writeEpubDest">
    		<properties>
    			<source>com.service.SaveLivre</source>
    			<scope>application</scope>
    		</properties>
    	</destination>
     
    </service>
    J'ai essayé d'exécuter mon appli avec le moins de code possible en modifiant notamment la signature de ma méthode, en lui passant simplement une chaine de caractère et en l'affichant, un peu comme dans le tuto et devinez quoi ! Ca marche !

    Mon problème viendrai-t-il d'un souci dans le passage de mon Livre, AS3 to Java ?

    Merci.

  2. #2
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2010
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2010
    Messages : 26
    Par défaut
    J'ai oublier de dire que j'avais aussi une tripoté de :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    java.lang.NoClassDefFoundError: com/adobe/dp/epub/opf/Resource
    La par contre je comprend vraiment pas, j'ai vérifié et je suis certain que cette classe est renseignée dans le classpath. De toute manière, j'ai inclu le .jar la contenant (en plus d'autre méthodes que j'utilise et qui proviennent de même jar et qui elles FONCTIONNENT !!!).

    Please, help !

  3. #3
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    319
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2004
    Messages : 319
    Par défaut
    As-tu convenablement mappé ta classe Livre.as et Livre.java?

Discussions similaires

  1. WCF-"Définir les types de données transmissibles entre applications"
    Par ralf91 dans le forum Windows Communication Foundation
    Réponses: 5
    Dernier message: 15/02/2010, 18h10
  2. Transmission d'une variable type JSON
    Par Invité dans le forum jQuery
    Réponses: 9
    Dernier message: 15/12/2009, 14h02
  3. transmission lien type show_book.php?vraicle=
    Par marcel marie dans le forum Langage
    Réponses: 1
    Dernier message: 20/11/2006, 11h12
  4. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36

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