Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flex
Flex Forum d'entraide sur la programmation Adobe Flex : applications Internet riches (RIA)
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/04/2011, 15h47   #1
Invité de passage
 
Homme Nicolas RIFFAUD
Étudiant
Inscription : novembre 2010
Messages : 25
Détails du profil
Informations personnelles :
Nom : Homme Nicolas RIFFAUD
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : novembre 2010
Messages : 25
Points : 0
Points : 0
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 :
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 :
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 :
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.
rillette87 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/04/2011, 16h53   #2
Invité de passage
 
Homme Nicolas RIFFAUD
Étudiant
Inscription : novembre 2010
Messages : 25
Détails du profil
Informations personnelles :
Nom : Homme Nicolas RIFFAUD
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : novembre 2010
Messages : 25
Points : 0
Points : 0
J'ai oublier de dire que j'avais aussi une tripoté de :

Code :
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 !
rillette87 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/04/2011, 14h07   #3
Membre éclairé
 
Inscription : janvier 2004
Messages : 319
Détails du profil
Informations personnelles :
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : janvier 2004
Messages : 319
Points : 384
Points : 384
As-tu convenablement mappé ta classe Livre.as et Livre.java?
Kantizbak est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 05h03.


 
 
 
 
Partenaires

Hébergement Web