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

Struts 1 Java Discussion :

LookUpDispatchAction Erreur does not contain specified method


Sujet :

Struts 1 Java

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut LookUpDispatchAction Erreur does not contain specified method
    Bonjour a tous,

    j'essaye d'utiliser le LookUpDispatchAction mais j'ai une erreur :

    Action[/modifierTerme] does not contain specified method

    Je ne trouve pas pourquoi ...

    Donc, voila ma classe Action :
    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
     
     
    public class ModifierTermeAction extends DispatchAction {
     
    	public ActionForward ajouter(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response) {
    		ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
     
    		Terme terme = new Terme();
    		TermeDAO ter = new TermeDAO();
    		ThesaurusDAO dao = new ThesaurusDAO();
     
    		terme.setIdTerme(modifierTermeForm.getIdTerme());
    		terme.setIdLangue(modifierTermeForm.getIdLangue());
    		terme.setIdThesaurus(modifierTermeForm.getIdThesaurus());
    		terme.setDescripteur(modifierTermeForm.getDescripteur());
    		terme.setNoteApplication(modifierTermeForm.getNoteApplication());
    		terme.setNoteHistorique(modifierTermeForm.getNoteHistorique());
    		terme.setType(modifierTermeForm.getType());
    		terme.setIdMt(modifierTermeForm.getIdMt());
    		terme.setTest(modifierTermeForm.getTest());
     
     
    		Transaction tx = ter.getSession().beginTransaction();
     
    		ter.save(terme);
     
    		tx.commit();
     
    		List theso = dao.findAll();
    		List termeList = ter.findAll();
     
    		request.setAttribute("afficherTheso", theso);
    		request.setAttribute("afficherTerme", termeList);
     
    		ter.getSession().close();
     
    		return mapping.findForward("success");
     
    	}
     
    	public ActionForward effacer(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response) {
    		ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
     
    		TermeDAO ter = new TermeDAO();		
    		ThesaurusDAO dao = new ThesaurusDAO();
     
    		List terme = ter.findByDescripteur(modifierTermeForm.getDescripteur());
    		Transaction tx = ter.getSession().beginTransaction();
     
    		if (terme.size() > 0) {			
    			for(Iterator iter = terme.iterator(); iter.hasNext();)
    			{
    				Terme result = (Terme) iter.next();
    				if((modifierTermeForm.getDescripteur()).equalsIgnoreCase(result.getDescripteur())){
    					System.out.println(result.getDescripteur());
    					ter.delete(result);
    					tx.commit();
    				}
    			}
    		}
    		List theso = dao.findAll();
    		List termeList = ter.findAll();
     
    		request.setAttribute("afficherTheso", theso);
    		request.setAttribute("afficherTerme", termeList);
     
    		ter.getSession().close();
     
    	return mapping.findForward("success");
     
    	}
     
     
    	@SuppressWarnings("unchecked")
    	protected Map getKeyMethodMap() {
    		Map map = new HashMap();
    		map.put("ajouter", "add");
    		map.put("effacer", "delete");
    		return map;
    	}
    Ensuite ma Jsp :
    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
     
    <body>
    		<html:form action="/modifierTerme">
    			descripteur : <html:text property="descripteur"/><html:errors property="descripteur"/><br/>
    		<html:submit property="monAction">
    		 <bean:message key="add"/>
    		</html:submit>
    		<html:submit property="monAction">
    		 <bean:message key="delete"/>
    		</html:submit>
    		<html:cancel/><br/><br/>
     
    			idTerme : <html:text property="idTerme"/><html:errors property="idTerme"/><br/>
    			idLangue : <html:text property="idLangue"/><html:errors property="idLangue"/><br/>
    			idThesaurus : <html:text property="idThesaurus"/><html:errors property="idThesaurus"/><br/>
    			noteApplication : <html:text property="noteApplication"/><html:errors property="noteApplication"/><br/>
    			noteHistorique : <html:text property="noteHistorique"/><html:errors property="noteHistorique"/><br/>
    			type : <html:text property="type"/><html:errors property="type"/><br/>
    			idMt : <html:text property="idMt"/><html:errors property="idMt"/><br/>
    			test : <html:text property="test"/><html:errors property="test"/><br/>
    		</html:form>
    	</body>

    et enfin, ma config struts :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     
     <action
          attribute="modifierTermeForm"
          input="/form/modifierTerme.jsp"
          name="modifierTermeForm"
          path="/modifierTerme"
          parameter="monAction"
          scope="request"
          type="bean.action.ModifierTermeAction">
          <set-property property="cancellable" value="true" />
          <forward name="success" path="/afficherTheso.jsp" />
        </action>
    J'ai trouvé ce systême sur le FAQ....

    Merci de votre aide ...

  2. #2
    Membre actif
    Homme Profil pro
    Développeur Java
    Inscrit en
    Août 2007
    Messages
    197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Août 2007
    Messages : 197
    Points : 246
    Points
    246
    Par défaut
    dans tes deux boutons submit, tu souhaites utiliser la propriété "monAction" qui permet à struts de savoir quelle méthode exécuter dans ton action.

    Dans ton cas je ne sais pas à quoi correspond les clés 'add' et 'delete', vu que tu ne nous as pas montré ton fichier ApplicationResources.properties qui contient la valeur associé à ces clés. Vérifie donc que ces valeurs associées à tes clés sont bien 'ajouter' et 'effacer'.

  3. #3
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    Bonjour,

    merci de ta réponse et en effet...
    mon fichier ApplicationResources.properties contient :

    add=AJOUTER
    delete=SUPPRIMER

    ce qui ne correspond pas à ca qu'il y a dans ma classe Action....

    Je teste et je dis quoi....

  4. #4
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    Bon, ben c'etait bien ca....

    les valeurs associées ont été rectifiées , et ca fonctionne....

    Merci...

  5. #5
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    Je réouvre le sujet car je viens de m'apercevoir que le "cancel" me renvoie une erreur :


    does not contain handler parameter named 'monAction'. This may be caused by whitespace in the label text.


    Pourtant j'ai bien un <set-property property="cancellable" value="true" />

    dans mon struts config pour l'action....

    Une petite idée peut etre ?

  6. #6
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Dans la LookupDispatchAction, il faut implémenter la méthode cancelled comme indiqué dans la FAQ Struts.

  7. #7
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    bonjour ,
    merci pour la réponse et oui...j'avais bien vu (après le post...) dans la FAQ...
    mais je vois pas comment implémenter cette méthode ...

    Serait -il possible d'avoir un petit exemple ???

  8. #8
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    Bon ben j'ai trouvé :

    Pour l'utilisation du lookUpDispatchAction,

    il faut une méthode comme celle ci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    public ActionForward execute (ActionMapping mapping, ActionForm form, 
    			HttpServletRequest request, HttpServletResponse response) throws Exception{
     
     
    		if (isCancelled(request)){
    		return(mapping.findForward("main"));
    		}
    		return (mapping.findForward("success"));
    		}
    Si c'est une simple Action, juste utilise un le booleen "isCancelled"...

    Voilà.

    Merci .

  9. #9
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    Bon...ben autant pour moi..ca ne marche pas du tout ...et du coup , moi je suis paumé ....


    Voila ma classe Action :
    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
     
     
    public class ModifierTermeAction extends DispatchAction {
     
    	/** 
             * Method execute
             * @param mapping
             * @param form
             * @param request
             * @param response
             * @return ActionForward
             */
    	@SuppressWarnings("unchecked")
    	protected Map getKeyMethodMap() {
    		Map map = new HashMap();
    		map.put("modify", "change");
    		map.put("add", "ajouter");
    		map.put("delete", "effacer");
    		return map;
    	}
     
    	@SuppressWarnings("unchecked")
    	public ActionForward change(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response) {
    		ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
     
    		TermeDAO ter = new TermeDAO();		
     
    		List termelist = ter.findByDescripteur(modifierTermeForm.getDescripteur());
     
    		if (termelist.size() > 0) {			
    			for(Iterator iter = termelist.iterator(); iter.hasNext();)
    			{
    				Terme result = (Terme) iter.next();
    				if((modifierTermeForm.getDescripteur()).equalsIgnoreCase(result.getDescripteur())){
     
    					modifierTermeForm.setIdTerme(result.getIdTerme());
    					modifierTermeForm.setIdLangue(result.getIdLangue());
    					modifierTermeForm.setIdThesaurus(result.getIdThesaurus());
    					modifierTermeForm.setDescripteur(result.getDescripteur());
    					modifierTermeForm.setNoteApplication(result.getNoteApplication());
    					modifierTermeForm.setNoteHistorique(result.getNoteHistorique());
    					modifierTermeForm.setType(result.getType());
    					modifierTermeForm.setIdMt(result.getIdMt());
    					modifierTermeForm.setTest(result.getTest());
     
    					System.out.println(
    					"result : "+(result.getDescripteur()));	
    				}
    			}
    		}
    		if (isCancelled(request)){
    			return(mapping.findForward("main"));
    			}
    	return mapping.findForward("change");
    	}
     
    	@SuppressWarnings("unchecked")
    	public ActionForward ajouter(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response) {
    		ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
     
    		Terme terme = new Terme();
    		TermeDAO ter = new TermeDAO();
    		ThesaurusDAO dao = new ThesaurusDAO();
     
    		terme.setIdTerme(modifierTermeForm.getIdTerme());
    		terme.setIdLangue(modifierTermeForm.getIdLangue());
    		terme.setIdThesaurus(modifierTermeForm.getIdThesaurus());
    		terme.setDescripteur(modifierTermeForm.getDescripteur());
    		terme.setNoteApplication(modifierTermeForm.getNoteApplication());
    		terme.setNoteHistorique(modifierTermeForm.getNoteHistorique());
    		terme.setType(modifierTermeForm.getType());
    		terme.setIdMt(modifierTermeForm.getIdMt());
    		terme.setTest(modifierTermeForm.getTest());
     
     
    		Transaction tx = ter.getSession().beginTransaction();
     
    		ter.save(terme);
     
    		tx.commit();
     
    		List theso = dao.findAll();
    		List termeList = ter.findAll();
     
    		request.setAttribute("afficherTheso", theso);
    		request.setAttribute("afficherTerme", termeList);
     
    		ter.getSession().close();
    		if (isCancelled(request)){
    			return(mapping.findForward("main"));
    			}
    		return mapping.findForward("ajouter");
     
    	}
     
    	@SuppressWarnings("unchecked")
    	public ActionForward effacer(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response) {
    		ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
     
    		TermeDAO ter = new TermeDAO();		
    		ThesaurusDAO dao = new ThesaurusDAO();
     
    		List terme = ter.findByDescripteur(modifierTermeForm.getDescripteur());
    		Transaction tx = ter.getSession().beginTransaction();
     
    		if (terme.size() > 0) {			
    			for(Iterator iter = terme.iterator(); iter.hasNext();)
    			{
    				Terme result = (Terme) iter.next();
    				if((modifierTermeForm.getDescripteur()).equalsIgnoreCase(result.getDescripteur())){
    					System.out.println(result.getDescripteur());
    					ter.delete(result);
    					tx.commit();
    				}
    			}
    		}
    		List theso = dao.findAll();
    		List termeList = ter.findAll();
     
    		request.setAttribute("afficherTheso", theso);
    		request.setAttribute("afficherTerme", termeList);
     
    		ter.getSession().close();
    		if (isCancelled(request)){
    			return(mapping.findForward("main"));
    			}
    		return mapping.findForward("effacer");
    	}
    }
    Voila..;donc, j'ai pas tout compris....

    Merci pour votre aide.

  10. #10
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2010
    Messages
    98
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Octobre 2010
    Messages : 98
    Points : 60
    Points
    60
    Par défaut
    Bon cette fois...
    ca fonctionne réellement !!!

    Voilà juste la méthode à rajouter :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    protected ActionForward cancelled(org.apache.struts.action.ActionMapping mapping,
                org.apache.struts.action.ActionForm form,
                HttpServletRequest request,
                HttpServletResponse response)
         throws Exception{
     
    		//traitement par défaut
     
    		return mapping.findForward("main");	//renvoi vers jsp accueil.
    	}
    Merci...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Erreur "file does not contain valid xml"
    Par moustaf_26 dans le forum AWT/Swing
    Réponses: 3
    Dernier message: 01/01/2013, 16h53
  2. Réponses: 2
    Dernier message: 25/01/2012, 15h13
  3. Réponses: 7
    Dernier message: 13/11/2009, 17h00
  4. Réponses: 0
    Dernier message: 05/08/2008, 19h22
  5. Réponses: 2
    Dernier message: 28/03/2007, 22h25

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