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

Discussion :

ninja framework formulaire

  1. #1
    Membre à l'essai
    Femme Profil pro
    etudiant
    Inscrit en
    Février 2016
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 31
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : etudiant

    Informations forums :
    Inscription : Février 2016
    Messages : 9
    Points : 10
    Points
    10
    Par défaut ninja framework formulaire
    bonjour a tous,

    je tiens a préciser que je suis débutante et la doc ne m'a pas beaucoup aider . Alors voila je veux creer des utilisateur sur mon application mais sans base de données, un utilisateur aurais un nom, prenom, login, password ensuite j'enregistre les informations dans un fichier preperties par exemple pour les utiliser lors de la connexion ou la modification

    voici mon formulaire dans index.ftl.html
    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
    <#import "../layout/defaultLayout.ftl.html" as layout> 
    <@layout.myLayout "Home page">    
    
    
    <h1>${i18n("hello.world")}</h1>
    <p>${i18n("hello.world.json")}</p>
    <form action="/utilisateur" method="post">
        <table class="form">
            <tr>
                <th><label for="nom"> Nom </label></th>
                <td><input class="input_full" type="text" id="nom" name="nom" />
    
                </td>
            </tr>
            <tr>
                <th><label for="prenom"> Prenom </label></th>
                <td><input class="input_full" type="prenom" id="prenom"
                    name="prenom" /></td>
            </tr>
    
            <tr>
                <th><label for="login"> Login </label></th>
                <td><input class="input_full" type="text" id="login"
                    name="login" /></td>
            </tr>
            
            <tr>
                <th><label for="password"> Password </label></th>
                <td><input class="input_full" type="password" id="password"
                    name="password" /></td>
            </tr>
        </table>
    
        <p>
            <input type="submit" value="Send" /> <input type="reset"
                value="Reset">
        </p>
    </form>
    <a href="/hello_world.json">Hello World Json</a>
    
    </@layout.myLayout>
    et voici mon controleur ApplicationController
    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
    /**
     * Copyright (C) 2013 the original author or authors.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    package controllers;
    
    import ninja.Context;
    import ninja.Result;
    import ninja.Results;
    import ninja.params.PathParam;
    
    import com.google.inject.Singleton;
    
    
    @Singleton
    public class ApplicationController {
    
        public Result index() {
    
            return Results.html();
    
        }
        
        public Result helloWorldJson() {
            
            SimplePojo simplePojo = new SimplePojo();
            simplePojo.content = "Hello World! Hello Json!";
    
            return Results.json().render(simplePojo);
    
        }
        
        public static class SimplePojo {
    
            public String content;
            
        }
       public Result utilisateur(Context context, utilisateur utilisateur){
    		
    	   return Results.html().render(utilisateur);
       }
    
        
    }
    et voici mon bean : utilisateur

    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
    package controllers;
    
    public class utilisateur {
    private String nom;
    private String prenom;
    private String login;
    private String password;
    public String getNom() {
    	return nom;
    }
    public void setNom(String nom) {
    	this.nom = nom;
    }
    public String getPrenom() {
    	return prenom;
    }
    public void setPrenom(String prenom) {
    	this.prenom = prenom;
    }
    public String getLogin() {
    	return login;
    }
    public void setLogin(String login) {
    	this.login = login;
    }
    public String getPassword() {
    	return password;
    }
    public void setPassword(String password) {
    	this.password = password;
    }
    
    
    }
    et voici ma classe routes
    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
    /**
     * Copyright (C) 2012 the original author or authors.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    package conf;
    
    
    import ninja.AssetsController;
    import ninja.Router;
    import ninja.application.ApplicationRoutes;
    import controllers.ApplicationController;
    
    public class Routes implements ApplicationRoutes {
    
        @Override
        public void init(Router router) {  
            
            router.GET().route("/").with(ApplicationController.class, "index");
            router.GET().route("/hello_world.json").with(ApplicationController.class, "helloWorldJson");
            router.GET().route("/utilisateur").with(ApplicationController.class, "utilisateur");
            
     
            ///////////////////////////////////////////////////////////////////////
            // Assets (pictures / javascript)
            ///////////////////////////////////////////////////////////////////////    
            router.GET().route("/assets/webjars/{fileName: .*}").with(AssetsController.class, "serveWebJars");
            router.GET().route("/assets/{fileName: .*}").with(AssetsController.class, "serveStatic");
            
            ///////////////////////////////////////////////////////////////////////
            // Index / Catchall shows index page
            ///////////////////////////////////////////////////////////////////////
            router.GET().route("/.*").with(ApplicationController.class, "index");
        }
    je suis vraiment bloqué et je sais pas comment continuer pour arrivé a faire ce que je veux c-à-d enregistrer mes utilisateurs et établir une connexion

  2. #2
    Membre habitué Avatar de Azerx
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2013
    Messages
    116
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2013
    Messages : 116
    Points : 185
    Points
    185
    Par défaut
    Bonjour,
    pour obtenir des réponses tu devrais tout d'abord rendre ton code lisible (je pense qu'aucun membre de ce forum n'est un compilateur).

    Enlève les informations inutiles, genre ça on s'en fiche:

    /**
    * Copyright (C) 2013 the original author or authors.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
    et entoure ton code des balises "code" (icone "#" quand tu écris un message).

    Si tu veux que quelqu'un t'aide, il faut que tu l'aide aussi

  3. #3
    Membre à l'essai
    Femme Profil pro
    etudiant
    Inscrit en
    Février 2016
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 31
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : etudiant

    Informations forums :
    Inscription : Février 2016
    Messages : 9
    Points : 10
    Points
    10
    Par défaut
    daccord

    mon formulaire dans index.ftl.html
    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
    <#import "../layout/defaultLayout.ftl.html" as layout>
    <@layout.myLayout "Home page">
    
    
    <h1>${i18n("hello.world")}</h1>
    <p>${i18n("hello.world.json")}</p>
    <form action="/utilisateur" method="post">
    <table class="form">
    <tr>
    <th><label for="nom"> Nom </label></th>
    <td><input class="input_full" type="text" id="nom" name="nom" />
    
    </td>
    </tr>
    <tr>
    <th><label for="prenom"> Prenom </label></th>
    <td><input class="input_full" type="prenom" id="prenom"
    name="prenom" /></td>
    </tr>
    
    <tr>
    <th><label for="login"> Login </label></th>
    <td><input class="input_full" type="text" id="login"
    name="login" /></td>
    </tr>
    
    <tr>
    <th><label for="password"> Password </label></th>
    <td><input class="input_full" type="password" id="password"
    name="password" /></td>
    </tr>
    </table>
    
    <p>
    <input type="submit" value="Send" /> <input type="reset"
    value="Reset">
    </p>
    </form>
    <a href="/hello_world.json">Hello World Json</a>
    
    </@layout.myLayout>

    mon controleur ApplicationController
    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
    package controllers;
    
    import ninja.Context;
    import ninja.Result;
    import ninja.Results;
    import ninja.params.PathParam;
    
    import com.google.inject.Singleton;
    
    
    @Singleton
    public class ApplicationController {
    
    public Result index() {
    
    return Results.html();
    
    }
    
    public Result helloWorldJson() {
    
    SimplePojo simplePojo = new SimplePojo();
    simplePojo.content = "Hello World! Hello Json!";
    
    return Results.json().render(simplePojo);
    
    }
    
    public static class SimplePojo {
    
    public String content;
    
    }
    public Result utilisateur(Context context, utilisateur utilisateur){
    
    return Results.html().render(utilisateur);
    }
    
    
    }

    mon bean : utilisateur
    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
    package controllers;
    
    public class utilisateur {
    private String nom;
    private String prenom;
    private String login;
    private String password;
    public String getNom() {
    return nom;
    }
    public void setNom(String nom) {
    this.nom = nom;
    }
    public String getPrenom() {
    return prenom;
    }
    public void setPrenom(String prenom) {
    this.prenom = prenom;
    }
    public String getLogin() {
    return login;
    }
    public void setLogin(String login) {
    this.login = login;
    }
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }
    
    
    }

    ma classe routes
    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
    package conf;
    
    
    import ninja.AssetsController;
    import ninja.Router;
    import ninja.application.ApplicationRoutes;
    import controllers.ApplicationController;
    
    public class Routes implements ApplicationRoutes {
    
    @Override
    public void init(Router router) {
    
    router.GET().route("/").with(ApplicationController.class, "index");
    router.GET().route("/hello_world.json").with(ApplicationController.class, "helloWorldJson");
    router.GET().route("/utilisateur").with(ApplicationController.class, "utilisateur");
    
    
    router.GET().route("/assets/webjars/{fileName: .*}").with(AssetsController.class, "serveWebJars");
    router.GET().route("/assets/{fileName: .*}").with(AssetsController.class, "serveStatic");
    
    
    
    
    router.GET().route("/.*").with(ApplicationController.class, "index");
    }

  4. #4
    Membre à l'essai
    Femme Profil pro
    etudiant
    Inscrit en
    Février 2016
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 31
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : etudiant

    Informations forums :
    Inscription : Février 2016
    Messages : 9
    Points : 10
    Points
    10
    Par défaut
    merci

  5. #5
    Membre habitué Avatar de Azerx
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2013
    Messages
    116
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2013
    Messages : 116
    Points : 185
    Points
    185
    Par défaut
    C'est déjà plus lisible, par contre la balise "quote" (petite bulle de texte) sert pour les citations, donc
    n'écrit pas ton texte comme ça

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

Discussions similaires

  1. Templates, Framework Formulaire
    Par Maxim71 dans le forum Langage
    Réponses: 1
    Dernier message: 10/02/2015, 17h46
  2. CSS et formulaire Zend Framework
    Par CinePhil dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 24/05/2011, 11h15
  3. Réponses: 3
    Dernier message: 25/07/2009, 02h46
  4. Liens et formulaire avec Zend Framework
    Par amarcil dans le forum Zend Framework
    Réponses: 6
    Dernier message: 12/08/2008, 12h17
  5. Réponses: 2
    Dernier message: 04/05/2007, 14h10

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