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 :

Exécution d'action répétée


Sujet :

Struts 1 Java

  1. #1
    Candidat au Club
    Inscrit en
    Décembre 2007
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 4
    Points : 3
    Points
    3
    Par défaut Exécution d'action répétée
    Bonjour,
    je développe actuellement une application web sous Eclipse. et depuis quelque temps j'ai toutes mes actions qui s'exécutent deux fois.Quant il s'agit de récupérer une liste de données,l'action s'exécute deux fois sans conséquence mais lorsque j'enregistre une nouvelle donnée le problème c'est qu'il me l'enregistre deux fois aussi.ça fais plus d'une semaine que je suis la dessus.
    Est que quelqu'un peut m'aider SVP?
    J'ai pas posé le codes source parce que je sais pas koi poster.
    mon appli est un peu large.
    Merci

  2. #2
    Membre averti Avatar de welcome_59
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mars 2007
    Messages
    203
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2007
    Messages : 203
    Points : 352
    Points
    352
    Par défaut
    Poste le code qui s'exécute 2 fois, ainsi que ceux qui l'appellent.

  3. #3
    Candidat au Club
    Inscrit en
    Décembre 2007
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 4
    Points : 3
    Points
    3
    Par défaut Développement J2EE/struts/hibernate(problème d'exécussion d'action)
    Citation Envoyé par welcome_59 Voir le message
    Poste le code qui s'exécute 2 fois, ainsi que ceux qui l'appellent.
    Voici par exemple une action simple pour enregistrer ou modifier un nouvel utilisateur:

    public class UserAction extends DispatchAction {
    private static final Log log = LogFactory.getLog("SIT-RH");


    public ActionForward addOrUpdate(

    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception{

    ActionForward forward= mapping.findForward("success");

    HttpSession session = request.getSession(false);
    if (session == null) {
    session = request.getSession();
    }


    UserForm userForm = (UserForm) form;
    String nom = userForm.getNom().trim();
    String prenom = userForm.getPrenom().trim();
    String tel = userForm.getTel();
    String fax = userForm.getFax();
    String agence = userForm.getAgence().trim();
    String trigramme = userForm.getTrigramme().trim();
    String pwd = userForm.getPwd().trim();
    int groupe = Integer.parseInt(userForm.getGroupe());

    try{
    //Mode Ajout
    if (userForm.getIdUtil()==0){

    TUserInscritHome userManager = new TUserInscritHome();
    TUserInscrit user = new TUserInscrit(nom,prenom,tel,fax,agence,trigramme,pwd);
    int idUser=userManager.addUser(user,groupe);
    userForm.setIdUtil(idUser);


    }

    //Mode modif
    else if(userForm.getIdUtil()!=0) {
    TUserInscritHome userManager = new TUserInscritHome();
    TUserInscrit user = new TUserInscrit(nom,prenom,tel,fax,agence,trigramme,pwd);
    user.setIdUtil(userForm.getIdUtil());
    if((userManager.updateUser(user,groupe)==true)){
    forward = listeUser(mapping, form,request, response);
    }
    }
    }
    catch (Exception e) {
    System.out.println( (this.getClass()).getName()+" -->>>> Pb création utilisateur : "+e.toString());
    forward = mapping.findForward("fail");
    }
    return forward;

    }

    et le formulaire où j'appelle de l'action:

    <script type="text/javascript">
    function setHidden(value){
    document.userForm.dispatch.value=value;
    }
    </script>


    <html:form action="/addOrUpdateUser" name = "userForm" type="com.teamlog.control.form.UserForm" >

    <html:hidden property = "dispatch" value="validate"/>
    <html:hidden name ="userForm" property="idUtil"></html:hidden>

    <div id="font_fd_bu">
    <table border="0" cellpadding="0" cellspacing="0" >



    <!-- Nom -->
    <tr height="15"><td width="6"></td></tr>

    <tr>
    <td align="left" width="160px"><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.name" /><span style="color:Red;">*</span>&nbsp;&nbsp;</span></label></td>

    <td colspan="1" align="left"><html:text name = "userForm" styleClass="password" tabindex="1" property="nom" maxlength="100" />
    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="nom"/>
    </logic:present></td>
    </tr>



    <!-- Prénom -->

    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.firstname" /><span style="color:Red;">*</span>&nbsp;&nbsp;</span></label></td>
    <td colspan="1" align="left"><html:text name = "userForm" styleClass="password" tabindex="1" property="prenom" maxlength="100" />
    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="prenom"/>
    </logic:present></td>
    </tr>



    <!-- Trigramme -->
    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.trigramme" /><span style="color:Red;">*</span>&nbsp;&nbsp;</span></label></td>
    <td colspan="1" align="left"><html:text name = "userForm" styleClass="login" tabindex="1" property="trigramme" maxlength="100" /><label for="credential" style="font-size: 11px;">@teamlog.com</label>
    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="trigramme"/>
    <html:errors property="trigrammeExiste"/>
    </logic:present></td>
    </tr>


    <!-- Mot de passe -->
    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.pwd" /><span style="color:Red;">*</span>&nbsp;&nbsp;</span></label></td>
    <td colspan="2" align="left"><html:text name = "userForm" styleClass="password" tabindex="2" property="pwd" maxlength="100" />
    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="pwd"/>
    </logic:present></td>
    </tr>


    <!-- Agence -->
    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.agence" /><span style="color:Red;">*</span>&nbsp;&nbsp;</span></label></td>

    <td colspan="1" align="left"><html:select name = "userForm" styleClass="agence" tabindex="1" property="agence" >
    <html:option value="Lannion">Lannion </html:option>
    <html:option value="Nantes">Nantes </html:option>
    <html:option value="Paris" >Paris </html:option>
    <html:option value="Rennes">Rennes </html:option>
    </html:select>
    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="agence"/>
    </logic:present></td></tr>


    <!-- Groupe -->
    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.groupe" /><span style="color:Red;">*</span>&nbsp;&nbsp;</span></label></td>

    <td colspan="1" align="left"><html:select name = "userForm" styleClass="groupe" tabindex="1" property="groupe" >
    <html:option value="" >Groupe</html:option>
    <html:option value="1" >RH</html:option>
    <html:option value="2" >Commerciaux</html:option>
    <html:option value="3" >Directeurs de projets</html:option>
    </html:select>
    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="groupe"/>
    </logic:present></td></tr>



    <!-- Téléphone -->

    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.tel"/>&nbsp;&nbsp;</span></label></td>
    <td colspan="1" align="left"><html:text name = "userForm" styleClass="champ" tabindex="2" property="tel" maxlength="100" />

    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="numError"/>
    </logic:present></td>

    </tr>

    <!-- Fax -->
    <tr height="5"><td colspan="1"></td></tr>
    <tr>
    <td align="left" ><label for="credential" style="font-size: 11px;"><span
    class="Style4">&nbsp;&nbsp;<bean:message key="addUser.fax" />&nbsp;&nbsp;</span></label></td>
    <td colspan="1" align="left">
    <html:text name = "userForm" styleClass="champ" tabindex="2" property="fax" maxlength="100" />

    <logic:present name="<%=Globals.ERROR_KEY%>">
    <html:errors property="numErrorFax"/>
    </logic:present></td>
    </tr>


    <tr height="10">
    <td>&nbsp;</td>
    </tr>
    </table>
    </div>
    <div id="font_b_bu"></div>

    <!-- Envoyer -->
    <table cellpadding="0" cellspacing="0" border="1" style=" width:100; font-size: 12px; margin-left: 50px;">
    <tr>
    <td align="center" valign="top"><html:image tabindex="3" pageKey="login.validate.image" onclick="setHidden('addOrUpdate')"/></td>
    </tr>
    </table>


    </html:form>

    Et dans le fichier struts-config.xml:

    <action
    path="/addOrUpdateUser"
    name="userForm"
    validate="true"
    scope="request"
    parameter = "dispatch"
    input="/jsp/zoneAdmin/gestion_utilisateurs/page_new_user.jsp"
    type="com.teamlog.control.action.UserAction">
    <forward name="success" path="page.add.ok" ></forward>
    <forward name="fail" path="/jsp/erreurs/page_new_user.jsp"></forward>
    <forward name = "liste_success" path="page.liste.user"></forward>
    </action>

Discussions similaires

  1. Exécuter une action quand on ferme le navigateur
    Par Leobaillard dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 08/01/2006, 12h41
  2. [Action] Exécuter l'action
    Par Tentative dans le forum AWT/Swing
    Réponses: 10
    Dernier message: 03/01/2006, 20h12
  3. Réponses: 1
    Dernier message: 25/10/2005, 13h25
  4. Exécuter une action à la fermeture d'une fenêtre
    Par wwave dans le forum Servlets/JSP
    Réponses: 12
    Dernier message: 28/07/2005, 15h15
  5. [FLASH MX PRO] Action répétée sur bouton
    Par dens63 dans le forum Flash
    Réponses: 4
    Dernier message: 15/04/2004, 14h16

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