Précédent   Forum des professionnels en informatique > Java > Général Java > Java & Mobiles > Java ME
Java ME Forum d'entraide Java Mobile Edition. Avant de poster -> FAQ Java ME, Cours Java ME
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 08/09/2011, 20h24   #1
Invité de passage
 
noureddine boukhari
Inscription : février 2011
Messages : 22
Détails du profil
Informations personnelles :
Nom : noureddine boukhari

Informations forums :
Inscription : février 2011
Messages : 22
Points : 1
Points : 1
Par défaut Erreur "java.lang.IndexOutOfBoundsException"

bonjour,
svp d'ou vient cette erreur
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
TRACE: <at java.lang.IndexOutOfBoundsException>, Exception caught in Display class
java.lang.IndexOutOfBoundsException
        at javax.microedition.lcdui.ChoiceGroup.checkIndex(), bci=16
        at javax.microedition.lcdui.ChoiceGroup.getString(), bci=8
        at biblio.bibliotheque.livre_auteur(bibliotheque.java:4106)
        at biblio.bibliotheque$3.itemStateChanged(bibliotheque.java:4214)
        at javax.microedition.lcdui.Form.uCallItemStateChanged(), bci=22
        at javax.microedition.lcdui.ChoiceGroupPopupLFImpl.uCallKeyPressed(), bci=296
        at javax.microedition.lcdui.ChoiceGroupPopupLFImpl.uCallPointerReleased(), bci=66
        at javax.microedition.lcdui.ChoiceGroupPopupLFImpl$CGPopupLayer.pointerInput(), bci=154
        at com.sun.midp.chameleon.CWindow.pointerInput(), bci=76
        at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handlePointerEvent(), bci=19
        at com.sun.midp.lcdui.DisplayEventListener.process(), bci=296
        at com.sun.midp.events.EventQueue.run(), bci=179
        at java.lang.Thread.run(Thread.java:619)
quand je modifie des données via textField ,les modifs seront effectué dans la bdd phpmysql mais leur réaffichage dans l'interface j2me ne sera pas et génére l'erreur ci dessus

merci de m'aidé
fortman1987 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/09/2011, 09h46   #2
Membre chevronné
 
Inscription : juin 2006
Messages : 444
Détails du profil
Informations personnelles :
Localisation : Allemagne

Informations forums :
Inscription : juin 2006
Messages : 444
Points : 680
Points : 680
C'est assez dur à dire avec aucun code sous les yeux.
A première vue je dirai que ton ChoiceGroup cherche à faire un getString() sur un index supérieur à son index maximal => IndexOutOfBoundsException
ex: ton ChoiceGroup a 3 élements de 0 à 2 et toi tu cherches un élément à l'index 4

Pourrais-tu fournir un peu plus de code ?
Anikinisan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/09/2011, 01h36   #3
Invité de passage
 
noureddine boukhari
Inscription : février 2011
Messages : 22
Détails du profil
Informations personnelles :
Nom : noureddine boukhari

Informations forums :
Inscription : février 2011
Messages : 22
Points : 1
Points : 1
Par défaut voila mon code

le code marche normalement mais apres a voir faire une modification des donnees il fait pas la mise a jour dans le choicegroup malgré que les donnés sont modifiée dans la base
voila le methode ou il se plante
(at biblio.bibliotheque.livre_auteur(bibliotheque.java:4106))
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
 
//recuperer auteur
public void livre_auteur() {
        choiceGroup2.deleteAll();
        String categorie = choiceGroup.getString(choiceGroup.getSelectedIndex());
     String titre = choiceGroup1.getString(choiceGroup1.getSelectedIndex());// (line 4106)   
 
        String parameter00;
 
        String url = "http://localhost/wwwbibwamp/admin/affichage/livre_auteur.php?";
        parameter00 = "categorie=" + categorie;
        parameter00 += "&titre=" + titre;
        parameter00 = urlEncode(parameter00);
        String c = connexion(url,parameter00);
 
       int i=0;
       StringBuffer bfr00 = new StringBuffer("");
       while (i!=c.length()){
       while (c.charAt(i)!='#') { bfr00.append(c.charAt(i));
                                         i++; }
 
       i++;
       choiceGroup2.append(bfr00.toString().trim(), null);
       bfr00.delete(0,c.length());
       }
  }
et voila mon item
(at biblio.bibliotheque$3.itemStateChanged(bibliotheque.java:4214)
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
 
ItemStateListener listener = new ItemStateListener() {
 
 
      public void itemStateChanged(Item item) {
 
        if (item == choiceGroup)
 
         if (choiceGroup.isSelected(choiceGroup.getSelectedIndex())) { livre_titre();
                                                                       livre_auteur();
                                                                       livre_annee();
                                                                       livre_code();
                                                                       livre_prix();
                                                                       livre_nbr();
                                                                       livre_dispo();
         }
        if (item == choiceGroup1)
 
         if (choiceGroup1.isSelected(choiceGroup1.getSelectedIndex())) { livre_auteur();
                                                                         livre_annee();
                                                                         livre_code();
                                                                         livre_prix();
                                                                         livre_nbr();
                                                                         livre_dispo();
 
      }
        if (item == choiceGroup2)
 
         if (choiceGroup2.isSelected(choiceGroup2.getSelectedIndex())) { livre_annee();
                                                                         livre_code();
                                                                         livre_prix();
                                                                         livre_nbr();
                                                                         livre_dispo();
 
      }
        if (item == choiceGroup4 )
 
         if (choiceGroup4.isSelected(choiceGroup4.getSelectedIndex())) {
                                                                         livre_code();
                                                                         livre_prix();
                                                                         livre_nbr();
                                                                         livre_dispo();
 
 
      }} };
comment peut on rafraichir les interfaces a chaque acces a une forme qui contient des choicegroup ???? cé ça le pb je pense
est ce qui'il ya une fonction predifini qui qui renitiialise choicegroupe sans selection manuel???

merci d'avance????
fortman1987 est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 12/09/2011, 14h24   #4
Membre chevronné
 
Inscription : juin 2006
Messages : 444
Détails du profil
Informations personnelles :
Localisation : Allemagne

Informations forums :
Inscription : juin 2006
Messages : 444
Points : 680
Points : 680
Je ne sais pas comment gérer les ChoiceGroup, donc je ne pourrai pas trop t'aider là dessus.

Mais apparemment ça pète dans ta méthode livre_auteur() et plus exactement là :
Code :
String titre = choiceGroup1.getString(choiceGroup1.getSelectedIndex());// (line 4106)
On en déduit que choiceGroup1.getSelectedIndex() n'est pas à jour et retourne un index qui n'existe pas.
Dans la doc, il est dit que si aucun élément n'est sélectionné, alors getSelectedIndex() renvoie -1.
C'est surement ce qui se passe.

Est-tu sûr que tu as un élément de sélectionné ?

Dans quel cas de itemStateChanged se trouve-t-on ?
Si c'est ce cas :
Code :
1
2
3
4
5
6
7
8
9
10
if (item == choiceGroup)
 
         if (choiceGroup.isSelected(choiceGroup.getSelectedIndex())) { livre_titre();
                                                                       livre_auteur();
                                                                       livre_annee();
                                                                       livre_code();
                                                                       livre_prix();
                                                                       livre_nbr();
                                                                       livre_dispo();
         }
alors peut-être que dans livre_titre() tu vides ton choiceGroup1 ou au moins fais quelque chose qui "reset" ta sélection dans ton choiceGroup1.
Anikinisan 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 20h08.


 
 
 
 
Partenaires

Hébergement Web