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

Spring Web Java Discussion :

[Spring MVC] onSubmit n'est pas exécuté


Sujet :

Spring Web Java

  1. #1
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 2
    Par défaut [Spring MVC] onSubmit n'est pas exécuté
    Bonjour,
    J'ai un problème avec la fonction onSubmit depuis plus d'une semaine et je trouve pas de solution.

    fichier JSP :

    Code html : 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
    <form id="preinscriptionForm" method="post"  >
     
     <fieldset>
     
        <legend> Informations personnelles </legend> 
     <p> 
     <label for="form_cin">CIN :</label>
     
                <spring:bind path="etudiant.cin">
                    <td>
                        <input type="text" size="30" name="${status.expression}" value="<c:out value="${status.value}"/>"> 
                    </td>
                    <td><font color="red"><c:out value="${status.errorMessage}"/> </font> </td>
               </spring:bind>
     
     </p>
     
    <p>
    <label for="form_nom">Nom :</label>
     
                <spring:bind path="etudiant.nom">
                    <td>
                        <input type="text" size="30" name="${status.expression}" value="<c:out value="${status.value}"/>">
                    </td>
                    <td><font color="red"><c:out value="${status.errorMessage}"/> </font> </td>
               </spring:bind>    
     
    </p>
    ................
    ..........

    Controlleur :

    Code xml : 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
     <bean name="userInformation" class="UserInformation" >
            <property name="etudiantManagerImpl">
                <ref bean="etudiantManagerImpl" />
            </property>
            <property name="provinceManagerImpl">
                <ref bean="provinceManagerImpl" />
            </property>
            <property name="anneeObtentionManagerImpl">
                <ref bean="anneeObtentionManagerImpl" />
            </property>
            <property name="serieManagerImpl">
                <ref bean="serieManagerImpl" />
            </property>
            <property name="academieManagerImpl">
                <ref bean="academieManagerImpl" />
            </property>
            <property name="sectionManagerImpl">
                <ref bean="sectionManagerImpl" />
            </property>
            <property name="commandName" value="etudiant" />
            <property name="commandClass" value="dao.Etudiant" />
            <property name="formView" value="information" />
     
            <property name="sessionForm" value="true" />
            <property name="validator">
                <ref bean="validateConfirmerEtudiant" />
            </property>
        </bean>
    Mapping :

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                       <prop key="/userLogin.htm">userConnexionController</prop>
                    <prop key="/erreurLogin.htm">erreurLoginController</prop>
                    <prop key="/information.htm">userInformation</prop>
                    <prop key="/seConnecter.htm">userLoginController</prop>
    ........
    ........

    ressourceBundle :

    ....
    information.class=org.springframework.web.servlet.view.InternalResourceView
    information.url=/WEB-INF/jsp/secure/users/information.jsp
    ....

    Controlleur UserInformation :

    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
    public class UserInformation extends SimpleFormController {
     
        private EtudiantManagerInterface etudiantManagerImpl;
        private ProvinceManagerInterface provinceManagerImpl;
        private SerieManagerInterface serieManagerImpl;
        private AnneeObtentionManagerInterface anneeObtentionManagerImpl;
        private AcademieManagerInterface academieManagerImpl;
        private SectionManagerInterface sectionManagerImpl;
     
     
        @Override protected Object formBackingObject(HttpServletRequest request)
                                        throws Exception {
           Etudiant etudiant = (Etudiant)(request.getSession().getAttribute("user"));
     
           return etudiant;
        }
        @Override
         protected Map referenceData(HttpServletRequest request) {
           Map data = new HashMap();
     
           List provinces = getProvinceManagerImpl().getProvinces();
           List anneesObtention = getAnneeObtentionManagerImpl().getAnneesObtention();
           List series = getSerieManagerImpl().getSeries();
           List academies = getAcademieManagerImpl().getAcademies();
           List sections = getSectionManagerImpl().getSections();
     
           data.put("provinces", provinces);
           data.put("academies", academies);
           data.put("series", series);
           data.put("anneesObtention", anneesObtention);
           data.put("sections", sections);
     
           return data;
       }
     
        @Override
        protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
     
            SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
            dateFormat.setLenient(false);
            binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
            binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
           // binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor("true", "false", false));
        }
     
        @Override
        protected void onBind(HttpServletRequest request, Object command,
                BindException errors) {
     
     
        }
     
        @Override
        protected ModelAndView onSubmit(HttpServletRequest request,
                                        HttpServletResponse response,
                                        Object command,
                                        BindException errors) throws Exception {   
     
            Etudiant etudiantSession = (Etudiant)(request.getSession().getAttribute("user"));
            Etudiant etudiant = (Etudiant)command; 
            etudiant.setMention(etudiantSession.getMention());
            etudiant.setDateInscription(etudiantSession.getDateInscription());
            etudiant.setPassword(etudiantSession.getPassword());
            etudiant.setConfirmation(etudiantSession.getConfirmation());
     
            getEtudiantManagerImpl().updateEtudiant(etudiant);
            request.getSession().removeAttribute("user");
            //return new ModelAndView("miseAJour","etudiant",etudiant);
            return new ModelAndView("etudiant_pdfView", "etudiant", etudiant);
        }
    Le probleme est le suivant : mon formulaire s'affiche correctement avec les champs préremplis.
    formBackingObject et referenceData sont bien executés, j'utilise des breakpoints pour m'assurer. Mais des que je click pour soumettre le formulaire, la méthode onSubmit() n'est pas appelée.

    c'est un problème que je rencontre seulement sur le seveur. sur mon pc de developpement tous se passe tres bien, la methode onsubmit est correctement appelée.

    c'est le meme fichier WAR utilisé sur ma machine que je deploie sur le serveur.

    J'ai verifié les logs, et il n'y a aucune erreur affichée.

  2. #2
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 2
    Par défaut
    Probleme resolu,

    l'erreur venait de mon fichier validate, je faisais un test sur un champ que j'avais supprimer de mon formulaire.
    onSubmit n'etait pas appele car le formulaire n'etait pas valide.

    Ce que je comprend pas c'est pourquoi ca marchait sur mon pc et pas sur le serveur

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

Discussions similaires

  1. Une partie du code n'est pas exécutée
    Par eddy37fr dans le forum VBA Access
    Réponses: 4
    Dernier message: 31/03/2008, 19h11
  2. Réponses: 7
    Dernier message: 23/10/2007, 11h36
  3. [Spring MVC] onSubmit n'est pas éxecuté
    Par jamalmoundir dans le forum Spring Web
    Réponses: 1
    Dernier message: 27/06/2007, 15h19
  4. [AJAX] Javascript n'est pas exécuté avec ajax.
    Par John6281 dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 27/02/2007, 14h35
  5. [Spring MVC][Validator] Ne stop pas si il y a une erreurs
    Par Hikage dans le forum Spring Web
    Réponses: 3
    Dernier message: 15/02/2006, 09h43

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