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

Seam Java Discussion :

[RichFaces] rich:Tree + Ajax = ClassCastException.


Sujet :

Seam Java

  1. #1
    Membre habitué

    Inscrit en
    Mai 2005
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Mai 2005
    Messages : 60
    Points : 171
    Points
    171
    Par défaut [RichFaces] rich:Tree + Ajax = ClassCastException.
    Bonjour.

    Me voici devant une erreur que je n'arrive pas a resoudre depuis hier midi.
    J'ai un rich:tree tout bateau, avec des classes qui implémentent TreeNode. J'ai mis mon Bean qui représente la racine de mon arbre en scope Page avec un zouli nom. J'ai un Bean qui s'occupe de charger mon arbre au lancement de la page.

    Tant que je fait rien en ajax (et que je suis pas en switchtype ajax) tout va bien. Des que je met en switchtype ajax ou que je tente de faire un traitement Ajax quand je clic sur un noeud , j'ai cette erreur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    GRAVE: "Servlet.service()" pour la servlet Faces Servlet a généré une exception
    java.lang.ClassCastException: cannot assign instance of org.jboss.seam.intercept.JavaBeanInterceptor to field fr.cpage.interfaces.admin.web.databean.LogicielData.listingLogicielData of type fr.cpage.interfaces.admin.web.databean.ListingLogicielData in instance of fr.cpage.interfaces.admin.web.databean.LogicielData


    Je vous met ci dessous la classe racine et la classe du 1er niveau de mon arbre ainsi que la partie correspondante au rf:Tree de ma jsp.

    Merci d'avance pour toute piste que vous pourriez me donner.

    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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
     
    @Name("listingLogicielData")
    @Scope(ScopeType.PAGE)
    public class ListingLogicielData implements TreeNode {
     
      private Map<Object,TreeNode> listLogicielData = new HashMap<Object, TreeNode>();
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#addChild(java.lang.Object, org.richfaces.model.TreeNode)
       */
      public void addChild(Object identifier, TreeNode child) {
        this.listLogicielData.put(identifier, child);
      }
     
      public void addLogiciel(LogicielData logicielData){
        this.listLogicielData.put(logicielData.getId(), logicielData);
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getChild(java.lang.Object)
       */
      public TreeNode getChild(Object id) {
     
        return this.listLogicielData.get(id);
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getChildren()
       */
      public Iterator getChildren() {
        return this.listLogicielData.entrySet().iterator();
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getData()
       */
      public Object getData() {
        return this;
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getParent()
       */
      public TreeNode getParent() {
        return null;
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#isLeaf()
       */
      public boolean isLeaf() {
        return this.listLogicielData.isEmpty();
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#removeChild(java.lang.Object)
       */
      public void removeChild(Object id) {
        this.listLogicielData.remove(id);
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#setData(java.lang.Object)
       */
      public void setData(Object arg0) {
        return;
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#setParent(org.richfaces.model.TreeNode)
       */
      public void setParent(TreeNode arg0) {
        return;
      }
     
      /**
       * Retourne la valeur de listLogicielData.
       * 
       * @return valeur de listLogicielData.
       */
      public Map<Object, TreeNode> getListLogicielData() {
        return this.listLogicielData;
      }
     
      /**
       * Définit la valeur de listLogicielData.
       * 
       * @param listLogicielData valeur de listLogicielData à définir.
       */
      public void setListLogicielData(Map<Object, TreeNode> listLogicielData) {
        this.listLogicielData = listLogicielData;
      }
     
      public String getType() {
        return "listingLogiciel";
      }
     
     
    }
    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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
     
    public class LogicielData implements TreeNode {
     
      private ListingLogicielData listingLogicielData;
      private Integer id;
      private String nom;
      private Map<Object,TreeNode> listConnecteurData = new HashMap<Object, TreeNode>();
      private String type = "logiciel";
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#addChild(java.lang.Object, org.richfaces.model.TreeNode)
       */
      public void addChild(Object identifier, TreeNode connecteurData) {
        this.listConnecteurData.put(identifier, connecteurData);
     
      }
     
      public void addConnecteurData(ConnecteurData connecteurData) {
        this.listConnecteurData.put(connecteurData.getId(), connecteurData);
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getChild(java.lang.Object)
       */
      public TreeNode getChild(Object identifier) {
     
        return this.listConnecteurData.get(identifier);
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getChildren()
       */
      public Iterator getChildren() {
        return this.listConnecteurData.entrySet().iterator();
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getData()
       */
      public Object getData() {
        return this;
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#getParent()
       */
      public TreeNode getParent() {
        return this.getListingLogicielData();
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#isLeaf()
       */
      public boolean isLeaf() {
        return this.listConnecteurData.isEmpty();
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#removeChild(java.lang.Object)
       */
      public void removeChild(Object identifier) {
        this.listConnecteurData.remove(identifier);
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#setData(java.lang.Object)
       */
      public void setData(Object arg0) {
        return;
      }
     
      /**
       * {@inheritDoc}
       * 
       * @see org.richfaces.model.TreeNode#setParent(org.richfaces.model.TreeNode)
       */
      public void setParent(TreeNode parent) {
        this.setListingLogicielData((ListingLogicielData)parent);
      }
     
      /**
       * Retourne la valeur de id.
       * 
       * @return valeur de id.
       */
      public Integer getId() {
        return this.id;
      }
     
      /**
       * Définit la valeur de id.
       * 
       * @param id valeur de id à définir.
       */
      public void setId(Integer id) {
        this.id = id;
      }
     
      /**
       * Retourne la valeur de nom.
       * 
       * @return valeur de nom.
       */
      public String getNom() {
        return this.nom;
      }
     
      /**
       * Définit la valeur de nom.
       * 
       * @param nom valeur de nom à définir.
       */
      public void setNom(String nom) {
        this.nom = nom;
      }
     
      /**
       * Retourne la valeur de listConnecteurData.
       * 
       * @return valeur de listConnecteurData.
       */
      public Map<Object, TreeNode> getListConnecteurData() {
        return this.listConnecteurData;
      }
     
      /**
       * Définit la valeur de listConnecteurData.
       * 
       * @param listConnecteurData valeur de listConnecteurData à définir.
       */
      public void setListConnecteurData(Map<Object, TreeNode> listConnecteurData) {
        this.listConnecteurData = listConnecteurData;
      }
     
      /**
       * Retourne la valeur de type.
       * 
       * @return valeur de type.
       */
      public String getType() {
        return this.type;
      }
     
      /**
       * Retourne la valeur de listingLogicielParentData.
       * 
       * @return valeur de listingLogicielParentData.
       */
      public ListingLogicielData getListingLogicielData() {
        return this.listingLogicielData;
      }
     
      /**
       * Définit la valeur de listingLogicielParentData.
       * 
       * @param listingLogicielParentData valeur de listingLogicielParentData à définir.
       */
      public void setListingLogicielData(ListingLogicielData ListingLogicielData) {
        this.listingLogicielData = ListingLogicielData;
      }
     
    }
    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
     
     
    <rf:tree switchType="client" style="width:180px" 
    ajaxSubmitSelection="true" value="#{listingLogicielData.data}" nodeSelectListener="#{gererTreeViewPage.renderToto}"
    var="item" nodeFace="#{item.type}">
     
                <rf:treeNode type="logiciel"  icon="/images/logiciel.gif">
     
                    <h:outputText value="#{item.nom}" />
     
                </rf:treeNode>
     
     
                <rf:treeNode type="connecteur"  icon="/images/connecteur.gif">
     
                    <h:outputText value="#{item.nom}" />
     
                </rf:treeNode>
    </rf:tree>
     
    <h:outputText value="monToto" rendered="#{gererTreeViewPage.toto}"/>
    PS :#{gererTreeViewPage.toto} correspond a un boolean que je passe a true dans mon traitement ajax (quand je selectionne un noeud)

  2. #2
    Membre régulier Avatar de LeGnome12
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2008
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2008
    Messages : 98
    Points : 109
    Points
    109
    Par défaut J'ai pas tout compris mais bon...
    Alors, je n'ai pas tout compris à ton post. Mais je pense que ton erreur est la même à laquelle je me suis butter il y a quelque temps.
    Alors, si je me souviens bien, elle venait du fait que mon arbre était dynamique. Donc si ton arbre est dynamique le problème est le suivant : rich:tree ne le gére pas !
    Bon une fois le problème identifier, bon courage pour le contourner !!

    Donc je t'explique comment j'ai trouvé la solution.

    C'est la le plus complexe, point par point :

    - Mon arbre est construit à partir d'une liste de groupe (rich:tree appelle une fonction qui prend la varriable lstGroup et qui en construit le nodeImpl)

    - Donc, je fais un saveState de ma liste de groupe.

    - Lorsque je veux changer ma liste (sur une modif de date dans mon cas) je pose ma liset à null et je la recharge.

    Bon ce qui faut retenir c'est le saveState de ce sur quoi ce base ton arbre!! Après il faut arriver à le gérer.

    je te souhaite bon courage !

Discussions similaires

  1. Réponses: 0
    Dernier message: 07/05/2012, 12h02
  2. [RichFaces+jsf+ajax] Navigation Tree avec rich:tree
    Par BigMac.com dans le forum JSF
    Réponses: 0
    Dernier message: 08/02/2011, 14h57
  3. Réponses: 0
    Dernier message: 20/04/2010, 19h25
  4. [richFaces] datatable dans rich:tree
    Par Malone dans le forum JSF
    Réponses: 0
    Dernier message: 30/09/2009, 14h11
  5. Réponses: 7
    Dernier message: 01/09/2009, 12h12

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