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 :

probleme de html:select onchange


Sujet :

Struts 1 Java

  1. #1
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut probleme de html:select onchange
    slt,

    j ai 2 listbox html:select é j aimerai bien de selection 1 é il te donnes la valeurs a 2 avec un bouton valider, voila ce truc:

    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
    function setAction(){
     
    serveurchoixListForm.action="serveurchoixList.do?do=serveur";
    serveurchoixListForm.submit();
    }
     
     
    <html:form action="serveurchoixList" ><html:hidden property="idserveur" />
    <table width="725" border="0" align="center" height="66">
    <tr>
    <td align="right"><font size="2" face="Verdana"><strong>Client :</strong></font></td>
    <td><html:select property="cli_code" onchange="setAction('serveurchoixList.do?action=idserveur')">
    <html:option value=""></html:option>
    <html:options collection="listClients" property="idcli" labelProperty="nomcli" />
    </html:select>
    </td>
    <td align="right"><font size="2" face="Verdana"><strong>Serveur :</strong></font></td>
    <td><html:select  property="srv_code">
    <html:option value=""></html:option>
    <html:options collection="listServeurs" property="idserveur" labelProperty="nomserveur" />
    </html:select>
    </td>
    </tr>
    <tr>
    <td valign="top"><br></td><td height="21" colspan="2" align="right"><p><font face="Arial"><span style="font-size:9pt;"></span></font>
     
        <html:submit>Valider</html:submit>
        <font face="Arial">      </font></p></td>
    </tr>
    </table>

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Deux petites choses avant de commencer :
    1) l'écriture sms n'est pas tellement agréable à lire => si tu veux que des gens te répondent, fais un chtit effort sur le plan de l'orthographe ... et évite la phonétique
    2) utilise la balise code pour....mettre ton code (ca facilite la lecture)

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Pour reprendre mon point "1)" je ne comprend pas ce que tu cherches à faire.....

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Visiblement c'est résolu.....

    C'est cool pour toi

  5. #5
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    ok
    voila j'ai 2 listbox la 1 pour les clients et 2 pour serveurs
    le probleme si en selectionne 1 pour la liste 1 je dois la reponse pour la liste 2

    et voila mon code:

    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
    <html:form action="serveurchoixList" ><html:hidden property="idserveur" />
    <table width="725" border="0" align="center" height="66">
    <tr>
    <td align="right"><font size="2" face="Verdana"><strong>Client :</strong></font></td>
    <td><html:select property="cli_code" onchange="setAction('serveurchoixList.do?action=idserveur')">
    <html:option value=""></html:option>
    <html:options collection="listClients" property="idcli" labelProperty="nomcli" />
    </html:select>
    </td>
     
     
    <td align="right"><font size="2" face="Verdana"><strong>Serveur :</strong></font></td>
    <td><html:select  property="srv_code">
    <html:option value=""></html:option>
    <html:options collection="listServeurs" property="idserveur" labelProperty="nomserveur" />
    </html:select>
    </td>
    </tr>
     
     
    <tr>
    <td valign="top"><br></td><td height="21" colspan="2" align="right"><p><font face="Arial"><span style="font-size:9pt;"></span></font>
     
        <html:submit>Valider</html:submit>
        <font face="Arial">      </font></p></td>
    </tr>
    </table>
    par exemple quand on choisit une valeur dans une première liste, on souhaite restreindre les valeurs possibles dans une seconde liste.

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Tu as mis ton post en résolu.....C'est fait exprès?

    D'autre part...finalement je doit être assez bête parce que avec ta phrase :
    le probleme si en selectionne 1 pour la liste 1 je dois la reponse pour la liste 2
    J'ai du mal je ne comprend pas vraiment......

    Tu veux changer la valeur selectionnée dans la liste 2 lorsque l'utilisateur change la valeur selectionnée dans la liste 1 c'est ca?

  7. #7
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    oui c ca mé je suis bête en francais aide moi stp

  8. #8
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Ok....
    Alors là il te faut repasser par ta classe action, à l'aide d'un truc du genre :
    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
    taFonctionJavascript(t, v){
        t.form.elements[0].value=v;
        t.form.submit();
    }
    
    
    <html:form action="serveurchoixList" ><html:hidden property="idserveur" />
    <html:hidden property="whatToDo"/>
    <table width="725" border="0" align="center" height="66">
    <tr>
    <td align="right"><font size="2" face="Verdana"><strong>Client :</strong></font></td>
    <td><html:select property="cli_code" onchange="taFonctionJavascript(this, 'updateSecondCollection')">
    <html:option value=""></html:option>
    <html:options collection="listClients" property="idcli" labelProperty="nomcli" />
    </html:select>
    </td>
    
    
    <td align="right"><font size="2" face="Verdana"><strong>Serveur :</strong></font></td>
    <td><html:select property="srv_code">
    <html:option value=""></html:option>
    <html:options collection="listServeurs" property="idserveur" labelProperty="nomserveur" />
    </html:select>
    </td>
    </tr>
    
    
    <tr>
    <td valign="top"><br></td><td height="21" colspan="2" align="right"><p><font face="Arial"><span style="font-size:9pt;"></span></font>
    
    <html:submit>Valider</html:submit>
    <font face="Arial"> </font></p></td>
    </tr>
    </table>
    Apres dans ton action tu récupères ce dont tu as besoin, tu mets à jour tout ca et tu redirige mvers ta jsp.....
    Et le tour est joué

  9. #9
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Je te donne une petite indication : recliques sur en bas à gauche de ton post..... Parce que là tu as mis ton problème en status "résolu" => personne ne va venir voir ce que tu dis dedans si tu n'enlève pas le status "résolu" de ton post

    Si ca peut t'aider

    ... et UTILISE LA BALISE "Code" (les # dans la barre d'outil)....C'est plus facile à lire les posts apres

  10. #10
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    ma class est :


    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
    public class ServeurchoixListAction extends Action {
    	/*
    	 * Generated Methods
    	 */
     
    	/** 
             * Method execute
             * @param mapping
             * @param form
             * @param request
             * @param response
             * @return ActionForward
             */
    	public ActionForward execute(ActionMapping mapping, ActionForm form,
    			                     HttpServletRequest request,HttpServletResponse response) {
     
    		ServeurchoixListForm serveurchoixListForm = (ServeurchoixListForm) form;
    		ServeursServices serveursServices = new ServeursServices();
    		ClientsServices clientsServices = new ClientsServices();
     
    		Clients clients = clientsServices.retournerClients(new Integer(-1));
    	    if (serveurchoixListForm.getCli_code()!=null && serveurchoixListForm.getCli_code().equals(""))
    	    {
    	    	clients = clientsServices.retournerClients(serveurchoixListForm.getCli_code());
    	    }
    	    Serveurs serveurs = serveursServices.retournerServeurs(new Integer (-1));
    	    if (serveurchoixListForm.getSrv_code()!=null && serveurchoixListForm.getSrv_code().equals(""))
    	    {
    	    	serveurs = serveursServices.retournerServeurs(serveurchoixListForm.getSrv_code());
    	    }
     
    	    request.setAttribute("listClients", clientsServices.collectionClients());
    	    request.setAttribute("listServeurs", serveursServices.collectionServeurs());
     
    		List listServeur = serveursServices.collectionServeurs();
    		serveurchoixListForm.setListServeurs(listServeur);
     
    		return mapping.findForward("showlist");
    	}
    desolé je fé tous ce ke tu di mé ca passe pas

  11. #11
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    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
    function choix(form, index) {
     
    for (var i = 0; i < form.Listbox1.length; i++) {
    form.Listbox1.options[i].text = "";
    form.Listbox1.options[i].value = "";
    }
    if (index == 1) {
    form.Listbox1.options[0].text = "Serveur A";
    } else if (index == 2) {
    form.Listbox1.options[0].text = "Serveur C";
    }
    if (index ==3) {
    form.Listbox1.options[0].text = "Serveur D";
    }
    form.Listbox1.selectedIndex = 0;
     
    }
     
     
     
     
     
     
     
    <select name="Listbox0" id="Listbox0" onchange="choix(this.form, this.selectedIndex)">
          <option value=""></option>
          <option value="Cosumar">Cosumar</option> 
          <option value="RAM">RAM</option>
          <option value="Lesieur">Lesieur</option>
    </select>
     
     
     
     
     
     
    <select name="Listbox1" size="1" id="Listbox1">
            <option></option>
            <option></option>
          </select>
    comme cet exemple juste avec html:select

  12. #12
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Ta classe 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
    taFonctionJavascript(t, v){
        t.form.elements[0].value=v;
        t.form.submit();
    }
    
    
    <html:form action="serveurchoixList" ><html:hidden property="idserveur" />
    <html:hidden property="whatToDo"/>
    <table width="725" border="0" align="center" height="66">
    <tr>
    <td align="right"><font size="2" face="Verdana"><strong>Client :</strong></font></td>
    <td><html:select property="cli_code" onchange="taFonctionJavascript(this, 'updateSecondCollection')">
    <html:option value=""></html:option>
    <html:options collection="listClients" property="idcli" labelProperty="nomcli" />
    </html:select>
    </td>
    
    
    <td align="right"><font size="2" face="Verdana"><strong>Serveur :</strong></font></td>
    <td><html:select property="srv_code">
    <html:option value=""></html:option>
    <html:options collection="listServeurs" property="idserveur" labelProperty="nomserveur" />
    </html:select>
    </td>
    </tr>
    
    
    <tr>
    <td valign="top"><br></td><td height="21" colspan="2" align="right"><p><font face="Arial"><span style="font-size:9pt;"></span></font>
    
    <html:submit>Valider</html:submit>
    <font face="Arial"> </font></p></td>
    </tr>
    </table>
    ta 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
    public class AdministrationAction extends Action{
     
    	/**
             *
             */
    	public ActionForward execute(ActionMapping mapping,
    			ActionForm form,
    			HttpServletRequest request,
    			HttpServletResponse response)
    			throws IOException, ServletException {
     
    if(form!=null){
         TonForm f = (TonForm)form;
         String whatToDo = f.getWhatToDo();
         System.out.println("whatToDo  = "+whatToDo );
    }	
    }
    }
    Ton formBean :
    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
    package form;
     
    public class TonForm extends ActionForm {
    	// tes champs
            // le champ à ajouter :
            private String whatToDo;
     
    /*   getters & setters */
             /**
             * @return the whatToDo
             */
    	public String getWhatToDo() {
    		return whatToDo;
    	}
     
    	/**
             * @param whatToDo the whatToDo to set
             */
    	public void setWhatToDo(String whatToDo) {
    		this.whatToDo = whatToDo;
    	}
    }

    Et tu exécutes ca, qu'écrit il dans la console : que vaut whatToDo lorsque tu sélectionnes un item dans la liste 1?

  13. #13
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    ca marche pas mé c pas grave je veu essayer une autre fois merci c gentille avec moi

    voila j ai des items de la lite clients et j ai items de la liste serveurs le probleme si je click sur la lite clients sur un item il affiche un item de la liste serveur ( on une relation avec client et serveur )

    s'il te plais tu peu me aidé, j ai une table user

    é dans le code j ai loginForm et loginAction et je cherche comment sécurisé mon login é password avec le test des zones de text

  14. #14
    Membre chevronné
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    376
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 376
    Par défaut
    Citation Envoyé par AnneB
    l'écriture sms n'est pas tellement agréable à lire
    Citation Envoyé par solfegepro
    je fé tous ce ke tu di mé ca passe pas
    Es-tu sûr de vraiment bien comprendre ce qu'on te dit ? Parce que si écrire correctement (c'est-à-dire avec un minimum d'efforts, non d'orthographe, mais de "comphéhensibilité") te pose problème, comment peut-on imaginer que tu puisses coder correctement ? J'imagine que tu ne vois pas le problème que pose le langage SMS. Normal. Je te répondrais que si tu passais 2 jours à essayer de répondre aux posts des débutants, tu comprendrais vite l'intérêt du "vrai" francais.

  15. #15
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut probleme de connexion des utilisateurs
    slt mes amis,

    j ai une table users(iduser,login,password,nom)

    et j'arrive pas comment connecté les utilisateurs de la table users

    voila mon code:

    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    struts-config.xml:
    <form-beans>
     
    <form-bean name="loginForm" type="com.jmd.test.struts.data.LoginForm" />
     
    <form-bean name="userEditForm" type="web.users.form.UserEditForm" />
    <form-bean name="userListForm" type="web.users.form.UserListForm" />
     
    </form-beans>
     
    <action-mappings>
     
      <action attribute="loginForm"
                input="/index.jsp"
                name="loginForm"
                path="/login"
                scope="request"
                type="com.jmd.test.struts.controleur.LoginAction">
     
          <forward name="echec" path="/index.jsp" />
          <forward name="succes" path="/menuprincipale.jsp" />
        </action>
    <action
          attribute="userListForm"
          name="userListForm"
          path="/userList"
          scope="request"
          type="web.users.action.UserListAction">
          <forward name="showlist" path="/jsp/users/listuser.jsp" />
        </action>
     
        <action attribute="userEditForm"
                name="userEditForm"
                parameter="do"
                path="/userEdit"
                scope="request"
                type="web.users.action.UserEditAction">
     
          <forward name="showadd" path="/jsp/users/adduser.jsp" />
          <forward name="showmodify" path="/jsp/users/edituser.jsp" />
          <forward name="showlist" path="/userList.do" />
        </action>
    </action-mappings>
     
    et voila LoginAction:
     
    package com.jmd.test.struts.controleur;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
     
    import com.jmd.test.struts.data.LoginForm;
     
    public final class LoginAction extends Action {
     
    	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res) 
     
    	throws Exception {
     
     
     
    	    String resultat = null;
     
    	String nomUtilisateur = ((LoginForm) form).getLogin();
    	String mdpUtilisateur = ((LoginForm) form).getPassword();
    	if (nomUtilisateur.equals("khalil") && mdpUtilisateur.equals("khalil")) {
     
    	resultat = "succes";
    	}
    	else 
    	{
    	resultat = "echec";
    	}
     
    	return mapping.findForward(resultat);
    	}
    	}
    package com.jmd.test.struts.controleur;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
     
    import com.jmd.test.struts.data.LoginForm;
     
    public final class LoginAction extends Action {
     
    	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res) 
     
    	throws Exception {
     
     
     
    	    String resultat = null;
     
    	String nomUtilisateur = ((LoginForm) form).getLogin();
    	String mdpUtilisateur = ((LoginForm) form).getPassword();
    	if (nomUtilisateur.equals("khalil") && mdpUtilisateur.equals("khalil")) {
     
    	resultat = "succes";
    	}
    	else 
    	{
    	resultat = "echec";
    	}
     
    	return mapping.findForward(resultat);
    	}
    	}
     
    et LoginForm :
     
    package com.jmd.test.struts.data;
     
    import javax.servlet.http.HttpServletRequest;
     
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    public class LoginForm extends ActionForm {
     
    	private static final long serialVersionUID = 1L;
     
    	String login;
    	String password;
    	String iduser = null;
    	String nom = null;
    	String admin = null;
     
     
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
     
    		ActionErrors errors = new ActionErrors();
     
    		if ((login == null) || (login.length() == 0))
    			errors.add(new ActionErrors(errors));
    		if ((password == null) || (password.length() == 0))
    		errors.add(new ActionErrors(errors));
    		return errors;
    	}
     
    	public void reset(ActionMapping mapping, HttpServletRequest request) {
    	this.password = null;
    	this.login = null;
    	}
     
    	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;
    	}
     
    	public String getIduser() {
    		return iduser;
    	}
     
    	public void setIduser(String iduser) {
    		this.iduser = iduser;
    	}
     
    	public String getNom() {
    		return nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	public String getAdmin() {
    		return admin;
    	}
     
    	public void setAdmin(String admin) {
    		this.admin = admin;
    	}
     
    	}
     
    et voila UserEditAction :
     
    package web.users.action;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.actions.DispatchAction;
     
    import web.modele.Users;
    import web.service.UsersServices;
    import web.users.form.UserEditForm;
     
    public class UserEditAction extends DispatchAction {
    	/*
    	 * Generated Methods
    	 */
     
    	/** 
             * Method execute
             * @param mapping
             * @param form
             * @param request
             * @param response
             * @return ActionForward
             */
     
    	public ActionForward editUser(ActionMapping mapping,ActionForm form,
    			                      HttpServletRequest request,HttpServletResponse response){
     
    		    UserEditForm userEditForm = (UserEditForm) form;
    			Integer id = new Integer(request.getParameter("iduser"));
    			UsersServices UsersServices=new UsersServices();
    			Users  users = UsersServices.retournerUsers(id);		
    			userEditForm.setUsers(users); 
     
    			return mapping.findForward("showmodify");
    			}
     
     
    	public ActionForward updateUser(ActionMapping mapping,ActionForm form,
    			                        HttpServletRequest request,HttpServletResponse response){
     
    		    UserEditForm usersEditForm = (UserEditForm) form;
    		    UsersServices usersServices = new UsersServices();
    		    Users  users = usersServices.retournerUsers(usersEditForm.getIduser());
    			users.setLoginuser(usersEditForm.getLoginuser());
    			users.setPassword(usersEditForm.getPassword());
    			users.setNomuser(usersEditForm.getNomuser());
    			users.setAdmin(usersEditForm.getAdmin());
    			usersServices.updateUsers(users);
     
    			return mapping.findForward("showlist");
    			}
     
     
    	public ActionForward deleteUser(ActionMapping mapping,ActionForm form,
                                        HttpServletRequest request,HttpServletResponse response){
     
    			Integer id = new Integer(request.getParameter("iduser"));
    			UsersServices usersServices = new UsersServices();
    			Users  users = usersServices.retournerUsers(id);	
    			usersServices.deleteUsers(users);
     
    			return mapping.findForward("showlist");
    			}
     
     
    	public ActionForward addUsers (ActionMapping mapping,ActionForm form,
    			                       HttpServletRequest request,HttpServletResponse response){
     
    			return mapping.findForward("showadd");
    			}
     
     
    	public ActionForward saveUsers(ActionMapping mapping,ActionForm form,
    			                       HttpServletRequest request,HttpServletResponse response){
     
    		    UserEditForm usersEditForm = (UserEditForm) form;
    		    UsersServices usersServices = new UsersServices();
    		    Users users = new Users();
    		    users.setLoginuser(usersEditForm.getLoginuser());
    		    users.setNomuser(usersEditForm.getNomuser());
    		    users.setPassword(usersEditForm.getPassword());
    		    users.setAdmin(usersEditForm.getAdmin());
     
    		    usersServices.addUsers(users);
     
    			return mapping.findForward("showlist");
    			}
    }
     
    et voila UserEditForm:
     
    package web.users.form;
     
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    import web.modele.Users;
     
     
    public class UserEditForm extends ActionForm {
    	/*
    	 * Generated Methods
    	 */
     
    	Users users = new Users();
    	private static final long serialVersionUID = 1L;
     
     
    	public Users getUsers() {
    		return users;
    	}
     
    	public void setUsers(Users users) {
    		this.users = users;
    	}
     
    	public String getAdmin() {
    		return users.getAdmin();
    	}
     
    	public Integer getIduser() {
    		return users.getIduser();
    	}
     
    	public String getLoginuser() {
    		return users.getLoginuser();
    	}
     
    	public String getNomuser() {
    		return users.getNomuser();
    	}
     
    	public String getPassword() {
    		return users.getPassword();
    	}
     
    	public void setAdmin(String admin) {
    		users.setAdmin(admin);
    	}
     
    	public void setIduser(Integer iduser) {
    		users.setIduser(iduser);
    	}
     
    	public void setLoginuser(String loginuser) {
    		users.setLoginuser(loginuser);
    	}
     
    	public void setNomuser(String nomuser) {
    		users.setNomuser(nomuser);
    	}
     
    	public void setPassword(String password) {
    		users.setPassword(password);
    	}
     
    	/** 
             * Method validate
             * @param mapping
             * @param request
             * @return ActionErrors
             */
    	public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
     
    		return null;
     
    	}
     
    	/** 
             * Method reset
             * @param mapping
             * @param request
             */
    	public void reset(ActionMapping mapping, HttpServletRequest request) {
     
    	}
     
    }
     
    et voila UserListAction:
     
    package web.users.action;
     
    import java.util.List;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
     
    import web.service.UsersServices;
    //import web.users.form.UserEditForm;
    import web.users.form.UserListForm;
     
    public class UserListAction extends Action {
    	/*
    	 * Generated Methods
    	 */
     
    	/** 
             * Method execute
             * @param mapping
             * @param form
             * @param request
             * @param response
             * @return ActionForward
             */
    	public ActionForward execute(ActionMapping mapping, ActionForm form,
    			                     HttpServletRequest request, HttpServletResponse response) {
     
    		UserListForm userListForm = (UserListForm) form;
    		UsersServices usersServices = new UsersServices();
    		List listUser = usersServices.collectionUsers();
    		userListForm.setListUsers(listUser);
    		return mapping.findForward("showlist");
     
    	}
     
    }
     
    et voila UserListForm :
     
    package web.users.form;
     
    import java.util.List;
     
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    import web.modele.Users;
     
    public class UserListForm extends ActionForm {
     
     
    	private List listUsers;
    	private Users users = new Users();
    	private static final long serialVersionUID = 1L;
     
    	/*
    	 * Generated Methods
    	 */
     
    	/** 
             * Method validate
             * @param mapping
             * @param request
             * @return ActionErrors
             */
    	public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
     
     
    		return null;
    	}
     
    	/** 
             * Method reset
             * @param mapping
             * @param request
             */
    	public void reset(ActionMapping mapping, HttpServletRequest request) {
     
    	}
     
    	public List getListUsers() {
    		return listUsers;
    	}
     
    	public void setListUsers(List listUsers) {
    		this.listUsers = listUsers;
    	}
     
    	public Users getUsers() {
    		return users;
    	}
     
    	public void setUsers(Users users) {
    		this.users = users;
    	}
     
    	public String getAdmin() {
    		return users.getAdmin();
    	}
     
    	public Integer getIduser() {
    		return users.getIduser();
    	}
     
    	public String getLoginuser() {
    		return users.getLoginuser();
    	}
     
    	public String getNomuser() {
    		return users.getNomuser();
    	}
     
    	public String getPassword() {
    		return users.getPassword();
    	}
     
    	public void setAdmin(String admin) {
    		users.setAdmin(admin);
    	}
     
    	public void setIduser(Integer iduser) {
    		users.setIduser(iduser);
    	}
     
    	public void setLoginuser(String loginuser) {
    		users.setLoginuser(loginuser);
    	}
     
    	public void setNomuser(String nomuser) {
    		users.setNomuser(nomuser);
    	}
     
    	public void setPassword(String password) {
    		users.setPassword(password);
    	}
     
     
    }
     
    et voila index.jsp :
     
    <%@ page language="java" pageEncoding="UTF-8"%>
     
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
     
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     
    <html:html locale="true"><head>
    	<title>index</title>
    	<html:base />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
    <html:img border="0" page="/ images/logo_main.gif" width="140" height="40"/>
    <body bgcolor="#CCCCCC"><br>
    	<DIV align="center">
    		<html:form action="login" focus="login">
     
    			<DIV align="left">
    				<FONT face="Georgia"></FONT>
    			</DIV>
    			<P align="center"></P>
     
    			<p align="center"> 
    				<font face="Georgia"> </font><font size="2" face="Verdana" color="#0000ff"><strong><u><br></u></strong></font></p><p align="center"><font size="2" face="Verdana" color="#0000ff"><strong><u>Veuillez vous identifier</u> :</strong></font></p><p align="center">  
    			</p>
    			<DIV align="left">
     
    		     <br>
    				<table width="50%" height="216" border="1" align="center">
      <tr>
        <th height="212" align="center" valign="middle" bgcolor="#999999" scope="row"><p align="center"><html:img border="0" page="/ images/log-top1.gif"  width="493"></html:img></p>
       <TABLE border="0" align="center" width="493" height="176">
     
    					<TR>
    						<TD height="34" align="right">
    							<html:img page="/ images/login.jpg" ></html:img><font size="4" face="Verdana"><strong><font size="2"> Login :</font> </strong></font>						</TD>
    						<TD align="left">
    							<font size="2" face="Arial"><html:text property="login" size="20" maxlength="20"></html:text></font>
     
    						<br></TD>
    					</TR>
    					<TR>
    						<TD height="31" align="right">
    							<html:img page="/ images/login.jpg" ></html:img><font size="4" face="Verdana"><strong><font size="2"><font size="2"> Password :</font></font> </strong></font>						</TD>
    						<TD align="left">
    							<font size="2" face="Arial"><html:password property="password" size="20" maxlength="20" redisplay="false"></html:password></font>
     
    						<br></TD>
    					</TR>
    					<TR>
    						<TD height="97" colspan="2" align="center"><FONT face="Georgia"></FONT><DIV align="center">&nbsp;  
    							    <html:submit property="action">Valider</html:submit>
    							<html:reset>Rétablir</html:reset>
     
    							</DIV>
    							<p align="center"> </p>
    					  </TD>
    					</TR>
    	  </TABLE>
     
        <p align="center"><html:img border="0" page="/ images/log-top2.gif"  width="493"></html:img><br></p><hr>
    <div align="center">
      <font color="#023264" size="2"> 
        <em><font style="font-weight: normal;">         Copyright &copy; 2007, pr&eacute;sent&eacute;  par M. DEKKAK KHALIL</font></em></font><font size="-1" color="#023264"><em>    </em> 
        <br> 
     
      </font>
    </div></th>
      </tr>
    </table>
     
    			</DIV>
    			<DIV align="left">
    			</DIV>
    			<DIV align="center"></DIV>
    		</html:form>
    	</DIV>
    </body>
    </html:html>
    é merci d'avance

    j aime bien te voir ce probleme .

  16. #16
    Membre Expert Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Par défaut
    je pense qu'avec des balises code ca aiderait à la comprehension.

  17. #17
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    j ai pas compri tu peut me aidé stp é merci pour ta reponse

  18. #18
    Membre Expert Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Par défaut
    Citation Envoyé par solfegepro
    j ai pas compri tu peut me aidé stp é merci pour ta reponse
    ¨
    Donc pour tout le monde te comprenne et pour que dans les prochains posts tu écrives plus correctement :

    me aidé = m'aider
    é = et
    peut = peux

    Met ton code entre des balises [ CODE ] [ /CODE ]

  19. #19
    Membre chevronné
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    376
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 376
    Par défaut
    Citation Envoyé par maxf1
    me aidé = m'aidé




    EDIT : le ptit edit discret => re-haha !

  20. #20
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    slt,

    j'ai 2 tables en mysql liées

    clients(idcli,nomcli,contact,telephonecontact,emailcontact)
    serveurs(idserveur,idcli,nomserveur,namespaceID,login,password,defaut)


    j ai 2 listes déroulantes n'ai pas liées entres eux c'est ca le problème

    j'ai déja récupérer le contenu extraire d'une base de données pour chacune, la première par le nomcli et la deuzième par nomserveur.

    le problème donc , je voudrais que quand je sélectionne une valeur dans la première liste , le contenu de la seconde s'ajuste parceque selon le choix dans la première liste, je n'aurai pas les mêmes éléments(items) dans la seconde.

    je travail avec myeclipse5 et stuts1.2 et hibernate et mysql et tomcat5.5

    donc voila mon code:
    choixserveur.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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    <head>
    <title>Liste des Serveurs</title>
    <script>
    function submitChange ( ){
    // --- Modification du parametre action qui va permettre d'appeller la bonne méthode JAVA a éxécuter.
    document.forms[0].action.value = 'change';
    // --- Soumission du formulaire.
    document.forms[0].submit;
    }
    </script>
    </head>
    <body>
     
    <table border="0" width="185" height="33">
    <tr>
    <td width="23">
    <p><font face="Arial"><span style="font-size:10pt;"><b><br></b></span></font></p>
    </td>
    <td style="border-bottom-width:1pt; border-bottom-color:rgb(102,102,102); border-bottom-style:solid;">
    <p class="Style2"><font face="Arial"><span style="font-size:10pt;"><b>&nbsp;</b></span></font><font face="Arial" color="#0000ff"><b>Choix du Serveurs</b></font> </p> </td>
    </tr>
    </table><br>
     
    <html:form action="serveurchoixList"><html:hidden property="idserveur" />
     
    <table width="725" border="0" align="center" height="66">
    <tr>
    <td align="right"><font size="2" face="Verdana"><strong>Client :</strong></font></td>
    <td><html:select property="cli_code" onchange="javascript:submitChange()">
    <html:option value=""></html:option>
    <html:options collection="listClients" property="idcli" labelProperty="nomcli" />
    </html:select>
    </td>
    <td align="right"><font size="2" face="Verdana"><strong>Serveur :</strong></font></td>
    <td><html:select property="srv_code">
    <html:option value=""></html:option>
    <html:options collection="listServeurs" property="idserveur" labelProperty="nomserveur" />
    </html:select>
    </td>
    </tr>
    <tr>
    <td valign="top"><br></td><td height="21" colspan="2" align="right"><p><font face="Arial"><span style="font-size:9pt;"></span></font>
     
    <html:submit>Valider</html:submit>
    <font face="Arial"> </font></p></td>
    </tr>
    </table>
    <table border="1" width="100%" align="center">
     
    <tr bgcolor="#999999">
    <th><font color="#FFFFFF">#</font></th>
    <th><font color="#FFFFFF">Client</font></th>
    <th><font color="#FFFFFF">Nom Serveur</font></th>
    <th><font color="#FFFFFF">NameSpace ID</font></th>
    <th><font color="#FFFFFF">Login</font></th>
    <th><font color="#FFFFFF">Defaut</font></th>
    </tr>
    <logic:empty name="serveurchoixListForm" property="listServeurs">
    <tr align="center">
    <td colspan="4"><div align="center"><strong>Pas de Serveur à afficher</strong></div></td>
    </tr>
    </logic:empty>
    <logic:notEmpty name="serveurchoixListForm" property="listServeurs">
    <logic:iterate name="serveurchoixListForm" property="listServeurs" id="element">
    <tr>
    <%-- print out the book informations --%>
    <td bgcolor="#EFEFEF"><bean:write name="element" property="idserveur" /></td>
    <td bgcolor="#EFEFEF"><bean:write name="element" property="clients.nomcli" /></td>
    <td bgcolor="#EFEFEF"><bean:write name="element" property="nomserveur" /></td>
    <td bgcolor="#EFEFEF"><bean:write name="element" property="namespaceId" /></td>
    <td bgcolor="#EFEFEF"><bean:write name="element" property="login" /></td>
    <td bgcolor="#EFEFEF"><bean:write name="element" property="defaut" /></td>
    </tr>
    </logic:iterate>
    </logic:notEmpty>
    </table>
    </html:form>
    </body>
    et ServeurchoixListAction

    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    package web.serveurs.action;
     
    import java.util.List;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
     
    import web.modele.Clients;
    import web.modele.Serveurs;
    import web.serveurs.form.ServeurchoixListForm;
    import web.service.ClientsServices;
    import web.service.ServeursServices;
     
    public class ServeurchoixListAction extends Action {
     
    /**
    * Method execute
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return ActionForward
    */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,HttpServletResponse response) {
     
    ServeurchoixListForm serveurchoixListForm = (ServeurchoixListForm) form;
    ServeursServices serveursServices = new ServeursServices();
    ClientsServices clientsServices = new ClientsServices();
     
    Clients clients = clientsServices.retournerClients(new Integer(-1));
    if (serveurchoixListForm.getCli_code()!=null && serveurchoixListForm.getCli_code().equals(""))
    {
    clients = clientsServices.retournerClients(serveurchoixListForm.getCli_code());
    }
    Serveurs serveurs = serveursServices.retournerServeurs(new Integer (-1));
    if (serveurchoixListForm.getSrv_code()!=null && serveurchoixListForm.getSrv_code().equals(""))
    {
    serveurs = serveursServices.retournerServeurs(serveurchoixListForm.getSrv_code());
    }
     
    request.setAttribute("listClients", clientsServices.collectionClients());
    request.setAttribute("listServeurs", serveursServices.collectionServeurs());
     
    List listServeur = serveursServices.collectionServeurs();
    serveurchoixListForm.setListServeurs(listServeur);
     
    return mapping.findForward("showlist");
    }
     
    public ActionForward updateServeur(ActionMapping mapping,ActionForm form,
    HttpServletRequest request,HttpServletResponse response){
     
    ServeurchoixListForm serveurschoixListForm = (ServeurchoixListForm) form;
    ServeursServices serveursServices = new ServeursServices();
     
    return mapping.findForward("showlist");
    }
     
    }
     
    et ServeurchoixListForm
     
    package web.serveurs.form;
     
    import java.util.List;
    import java.util.Set;
     
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
     
    import web.modele.Clients;
    import web.modele.Serveurs;
     
    public class ServeurchoixListForm extends ActionForm {
    /*
    * Generated Methods
    */
    private Integer srv_code;
    private Integer cli_code;
    private List listServeurs;
    private Serveurs serveurs = new Serveurs();
    private static final long serialVersionUID = 1L;
     
    /**
    * Method validate
    * @param mapping
    * @param request
    * @return ActionErrors
    */
    public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
     
    return null;
    }
     
    /**
    * Method reset
    * @param mapping
    * @param request
    */
    public void reset(ActionMapping mapping, HttpServletRequest request) {
     
    }
     
    public List getListServeurs() {
    return listServeurs;
    }
     
    public void setListServeurs(List listServeurs) {
    this.listServeurs = listServeurs;
    }
     
    public Serveurs getServeurs() {
    return serveurs;
    }
     
    public void setServeurs(Serveurs serveurs) {
    this.serveurs = serveurs;
    }
     
    public Clients getClients() {
    return serveurs.getClients();
    }
     
    public String getDefaut() {
    return serveurs.getDefaut();
    }
     
    public Integer getIdserveur() {
    return serveurs.getIdserveur();
    }
     
    public String getLogin() {
    return serveurs.getLogin();
    }
     
    public String getNamespaceId() {
    return serveurs.getNamespaceId();
    }
     
    public String getNomserveur() {
    return serveurs.getNomserveur();
    }
     
    public Set getPackageses() {
    return serveurs.getPackageses();
    }
     
    public String getPassword() {
    return serveurs.getPassword();
    }
     
    public void setClients(Clients clients) {
    serveurs.setClients(clients);
    }
     
    public void setDefaut(String defaut) {
    serveurs.setDefaut(defaut);
    }
     
    public void setIdserveur(Integer idserveur) {
    serveurs.setIdserveur(idserveur);
    }
     
    public void setLogin(String login) {
    serveurs.setLogin(login);
    }
     
    public void setNamespaceId(String namespaceId) {
    serveurs.setNamespaceId(namespaceId);
    }
     
    public void setNomserveur(String nomserveur) {
    serveurs.setNomserveur(nomserveur);
    }
     
    public void setPackageses(Set packageses) {
    serveurs.setPackageses(packageses);
    }
     
    public void setPassword(String password) {
    serveurs.setPassword(password);
    }
     
    public Integer getCli_code() {
    return cli_code;
    }
     
    public void setCli_code(Integer cli_code) {
    this.cli_code = cli_code;
    }
     
    public Integer getSrv_code() {
    return srv_code;
    }
     
    public void setSrv_code(Integer srv_code) {
    this.srv_code = srv_code;
    }
     
    }
    et ServeursServices

    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
    package web.service;
     
    import java.util.List;
     
    import org.hibernate.Criteria;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
    import org.hibernate.criterion.Expression;
     
    import web.hibernate.HibernateSessionFactory;
    import web.modele.Serveurs;
     
    public class ServeursServices {
     
    public void addServeurs(Serveurs serveurs)
    {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    session.save(serveurs);
    tx.commit();
    //session.close();
    }
     
    public void updateServeurs(Serveurs serveurs)
    {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    session.update(serveurs);
    //session.createSQLQuery("");
    tx.commit();
    //session.close();
    }
     
    // cette methode permet la suppression d'un serveur
     
    public void deleteServeurs(Serveurs serveurs)
    {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    session.delete(serveurs);
    tx.commit();
    //session.close();
    }
     
    // cette methode permet de ramener la liste des serveurs
     
    public List collectionServeurs()
    {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Criteria cri = session.createCriteria(Serveurs.class);
    List result = cri.list();
    tx.commit();
    //session.close();
    return result;
    }
     
    // cette methode permet de retourner un serveur par id
     
    public Serveurs retournerServeurs(Integer idserveur)
    {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Serveurs result = (Serveurs)session.get(Serveurs.class,idserveur);
    tx.commit();
    //session.close();
    return result;
    }
     
    // cette methode permet de retourner un serveur par nomserveur
     
    public Serveurs retournerServeurs(String nomserveur)
    {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Serveurs result = (Serveurs)session.get(Serveurs.class,nomserveur);
    tx.commit();
    //session.close();
    return result;
    }
     
    public List collectionServeurs2(String nomserveurs, Serveurs serveurs) {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Criteria cri = session.createCriteria(Serveurs.class);
     
     
    if(nomserveurs!=null && nomserveurs.equals("")==false){
     
    cri.add(Expression.eq("nomserveurs", nomserveurs));
     
    }
    if(serveurs!=null){
     
    cri.add(Expression.eq("Serveurs", serveurs));
     
    }
     
    List result = cri.list();
    tx.commit();
    // session.close();
    return result;
    }
    }
    et ClientsServices

    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
    package web.service;
     
    import java.util.List;
     
    import org.hibernate.Criteria;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
    import org.hibernate.criterion.Expression;
     
    import web.hibernate.HibernateSessionFactory;
    import web.modele.Clients;
     
    public class ClientsServices {
     
    public void addClients(Clients clients){
     
     
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    session.save(clients);
    tx.commit();
    //session.close();
    }
     
    public void updateClients(Clients clients){
     
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    session.update(clients);
    tx.commit();
    //session.close();
    }
     
    // cette methode permet la suppression d'un client
     
    public void deleteClients(Clients clients){
     
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    session.delete(clients);
    tx.commit();
    //session.close();
    }
     
    // cette methode permet de ramener la liste des clients
     
    public List collectionClients() {
     
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Criteria cri = session.createCriteria(Clients.class);
    List result = cri.list();
    tx.commit();
    //session.close();
    return result;
    }
     
    // cette methode permet de retourner un client par id
     
    public Clients retournerClients(Integer id){
     
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Clients result = (Clients)session.get(Clients.class,id);
    tx.commit();
    //session.close();
    return result;
    }
     
    // cette methode permet de retourner un client par nomcli
     
    public Clients retournerClients(String nomcli){
     
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Clients result = (Clients)session.get(Clients.class,nomcli);
    tx.commit();
    //session.close();
    return result;
    }
    public List collectionClients2(String nomclients, Clients clients) {
    Session session = HibernateSessionFactory.getSession();
    Transaction tx = session.beginTransaction();
    Criteria cri = session.createCriteria(Clients.class);
     
     
    if(nomclients!=null && nomclients.equals("")==false){
     
    cri.add(Expression.eq("nomclients", nomclients));
     
    }
    if(nomclients!=null){
     
    cri.add(Expression.eq("Clients", clients));
     
    }
     
    List result = cri.list();
    tx.commit();
    // session.close();
    return result;
    }
    }

    et merçi d'avance mes amis.

Discussions similaires

  1. html select onchange
    Par khaoula_14_05 dans le forum Struts 1
    Réponses: 6
    Dernier message: 24/10/2008, 14h51
  2. <html:select> et onchange
    Par zybay dans le forum Struts 1
    Réponses: 24
    Dernier message: 27/04/2007, 12h07
  3. [ STRUTS ] <html:select onchange=...>
    Par Houbbba dans le forum Struts 1
    Réponses: 6
    Dernier message: 24/04/2006, 13h54
  4. [HTML] Probleme avec les événement OnChange et OnClick
    Par G_Kill dans le forum Balisage (X)HTML et validation W3C
    Réponses: 8
    Dernier message: 04/05/2005, 16h06

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