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

Servlets/JSP Java Discussion :

Modification d'une ligne dans une table


Sujet :

Servlets/JSP Java

  1. #1
    Futur Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2011
    Messages : 15
    Points : 6
    Points
    6
    Par défaut Modification d'une ligne dans une table
    Bonjour,

    je suis en train de développer une application en J2EE, struts et hibernate.
    je suis bloqué sur un problème de modification de ligne, j'affiche une table et dans chaque ligne de cette table j'ai deux butons le premier pour valider la demande (ça permet de passer le statue demande à validé) et le deuxième pour refuser' le statue passe a refusé).
    mais ça marche que pour la premier ligne et quand je fais la même opération pour les autres lignes j'ai l'erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    java.lang.NoSuchMethodException: gestion.conge.gestionconge.ui.usersAction.actions.AfficherDemandeEnvoyeParEmployeManageAction.(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    	java.lang.Class.getMethod(Unknown Source)
    	org.apache.struts.actions.DispatchAction.getMethod(DispatchAction.java:322)
    	org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:262)
    	org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
    	org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    	org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    	org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    	gestion.conge.gestionconge.ui.HibernateFilter.doFilter(HibernateFilter.java:35)
    pourtant quand j'ai regarde le code source de la page j'ai bien un form pour chaque ligne donc je vois pas pourquoi j'arrive pas à faire ce que je veux
    voici mon code 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
    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
     
     
    <html:html>
     
     
    	<head>
    		<title><bean:message key="listeDemandeConge"/></title>
    	</head>
    	<body>
     
    <table border="1">
    			<thead>
    				<tr>
    				<th><bean:message key="numero_demande"/></th>
    					<th><bean:message key="date_demande_conge"/></th>
    					<th><bean:message key="date_depart"/></th>
    					<th><bean:message key="date_fin"/></th>
    					<th><bean:message key="reponse_conge"/></th>
    					<th><bean:message key="nb_jour_conge"/></th>
    				</tr>
    			</thead>
    			<tbody>
    				<logic:iterate id="elementDemande" name="demande3" type="gestion.conge.gestionconge.business.conge.DemandeConge">
    					<html:form action="AfficherDemandeEnvoyeParEmployeManageAction" method="POST">
    					<html:hidden property="event" value=""/>
    					<tr>
    						<td><bean:write name="elementDemande" property="idDemandeConge"/></td>
    						<html:hidden property="id" value= "<%=elementDemande.getId()%>" />
    						<td><bean:write name="elementDemande" property="dateDemandeCongeFormatee"/></td>
    						<td><bean:write name="elementDemande" property="dateDepartFormatee"/></td>
    						<td><bean:write name="elementDemande" property="dateFinFormatee"/></td>
    						<td><bean:write name="elementDemande" property="reponseConge"/></td>
    						<td><bean:write name="elementDemande" property="nbJourConge"/></td>
    						<th>
    						<html:submit property="validerDemande" value="valider"  onclick="valider()"/>
     						</th>
     						<th>
    						<html:submit property="validerDemande" value="refuser"  onclick="refuser()"/>
     						</th>
     
    					</tr>
    					  </html:form>
    				</logic:iterate>
    			</tbody>
    		</table>
     
    		</body>
    <script language=javascript>
    function valider()
    {
    var p = confirm('Etes vous sur de vouloir supprimer votre demande de conge ? Cette opération est irréversible  ?')
     
    if(p == true)
    	AfficherDemandeEnvoyeParEmployeManageForm.event.value = 'validerDemande'
    }
     
    function refuser()
    {
    var p = confirm('Etes vous sur de vouloir supprimer votre demande de conge ? Cette opération est irréversible  ?')
     
    if(p == true)
    	AfficherDemandeEnvoyeParEmployeManageForm.event.value = 'refuserDemande'
    }
    </script>
    <html:link href="CongeManagerAction.do?event=init">retour vers la page demande conge</html:link>
     
    </html:html>
    et mon code 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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
     
     /**
         * Process the specified HTTP request for <strong>validerDemande</strong> event.
         * 
         * @param mapping The ActionMapping used to select this instance
         * @param form The optional ActionForm bean for this request (if any)
         * @param request The HTTP request we are processing
         * @param response The HTTP response we are creating
         *
         * @exception Exception if an input/output error or servlet exception occurs
         */
    	public ActionForward validerDemande(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    		log.debug("Starting");
    		String returnCode = PAGE_SELF;
    		AfficherDemandeEnvoyeParEmployeManageForm afficherDemandeEnvoyeParEmployeManageForm = (AfficherDemandeEnvoyeParEmployeManageForm)form;
    		//Start of user code method validerDemande
    		List<DemandeConge> demande3 = new ArrayList<DemandeConge>();
    		Employe employe = (Employe)request.getSession().getAttribute(gestion.conge.gestionconge.ui.UiConstants.CURRENT_USER);
    		IDemandeCongeDao dao = GestioncongeDaoFactory.getDemandeCongeDao();
    		IEmployeDao dao1 = GestioncongeDaoFactory.getEmployeDao();
    		String id=  request.getParameter("id");
    		//demande1 = dao.findDemandeAnnulationByDateDepartEtDateFin(employe);
    		DemandeConge demandeValide = new DemandeConge();
    		demandeValide  = dao.findDemandeCongeById(id);
    		demandeValide.setReponseConge("demande validé");
    		dao.updateDemandeConge(demandeValide);
    		returnCode  =  PAGE_SUCCESSVALIDATION ;
    		//End of user code
    		return mapping.findForward(returnCode);
    	}
        /**
         * Process the specified HTTP request for <strong>refuserDemande</strong> event.
         * 
         * @param mapping The ActionMapping used to select this instance
         * @param form The optional ActionForm bean for this request (if any)
         * @param request The HTTP request we are processing
         * @param response The HTTP response we are creating
         *
         * @exception Exception if an input/output error or servlet exception occurs
         */
    	public ActionForward refuserDemande(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    		log.debug("Starting");
    		String returnCode = PAGE_SELF;
    		AfficherDemandeEnvoyeParEmployeManageForm afficherDemandeEnvoyeParEmployeManageForm = (AfficherDemandeEnvoyeParEmployeManageForm)form;
    		//Start of user code method refuserDemande
    		List<DemandeConge> demande3 = new ArrayList<DemandeConge>();
    		Employe employe = (Employe)request.getSession().getAttribute(gestion.conge.gestionconge.ui.UiConstants.CURRENT_USER);
    		IDemandeCongeDao dao = GestioncongeDaoFactory.getDemandeCongeDao();
    		IEmployeDao dao1 = GestioncongeDaoFactory.getEmployeDao();
    		String id=  request.getParameter("id");
     
    		DemandeConge demandeValide = new DemandeConge();
    		demandeValide  = dao.findDemandeCongeById(id);
    		demandeValide.setReponseConge("demande refusé");
    		dao.updateDemandeConge(demandeValide);
    		returnCode  =  PAGE_SUCCESSREFUS  ;
    		//End of user code
    		return mapping.findForward(returnCode);
    	}
    je pense qu'il récupère mal l'id mais je ne vois pas comment faire pour corriger ça.

    merci d'avance.
    Cordialement,

  2. #2
    Membre confirmé

    Homme Profil pro
    Chomeur
    Inscrit en
    Juin 2006
    Messages
    347
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Chomeur

    Informations forums :
    Inscription : Juin 2006
    Messages : 347
    Points : 452
    Points
    452
    Par défaut
    Salut,

    Un peu au pif, je dirai que comme tu es dans un "logic:iterate", tu pourrai bien avoir besoin d'un petit "indexed" quelque part? Vérifie le code html généré, si tu as un conflit d'id sur un champ, tu le trouvera plus facilement.

    Sinon j'ai un doute sur le fait que les deux submit utilise le même "property = 'validerDemande'".

    Bon courage,
    a++

  3. #3
    Membre éprouvé Avatar de noOneIsInnocent
    Homme Profil pro
    Inscrit en
    Mai 2002
    Messages
    1 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 037
    Points : 1 161
    Points
    1 161
    Par défaut
    Bonjour

    je trouve que mettre autant de formulaire que de ligne risque de t'applorter beaucoup de probleme

    A mon avis il serait plus simple de faire un seul formulaire et quand tu cliques sur un des bouttons tu appelles une méthode Javascript qui met à jour des champs hidden avec des valeurs d'indexes que tu récuperes dans ton unique action

Discussions similaires

  1. Récupérer une information d'une ligne dans une table
    Par Lebas dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 12/04/2013, 10h24
  2. Colorer une ligne dans une image d'une interface
    Par yasmine2013 dans le forum Interfaces Graphiques
    Réponses: 0
    Dernier message: 27/05/2012, 22h32
  3. Réponses: 4
    Dernier message: 15/10/2009, 13h33
  4. [E-00] Syntaxe pour insérer une ligne ou une colonne dans une feuille
    Par Benjycool dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 02/02/2009, 09h27
  5. Réponses: 3
    Dernier message: 29/01/2008, 12h08

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