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 :

Action lancée deux fois


Sujet :

Struts 1 Java

  1. #1
    Membre averti
    Profil pro
    Responsable R&D
    Inscrit en
    Octobre 2008
    Messages
    29
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Responsable R&D

    Informations forums :
    Inscription : Octobre 2008
    Messages : 29
    Par défaut Action lancée deux fois
    Bonjour,

    Voila La page sur laquelle je travaille permet de lancer une recherche selon l'id.

    L'utilisateur saisis l'id et appuis sur Entrée. A ce moment, je lui permet si le résultat de la recherche est unitaire de le mettre au panier.

    Le soucis s'est que quand j'appuie sur entrée l'action est lancé deux fois, en parallèle.

    Voici le 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
    <script type="text/javascript">
    	var windowDetailArticle = null;
     
    	function checkEnter() {
    		if(event.keyCode==13) {
    			document.searchFullForm.autoAddToCart.value=true;
    			document.searchFullForm.submit();
    		}
    	}
     
    </script>
    <html:errors/>
    <html:messages id="message" message="true">
    			<p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CC0000">
                    	<bean:write name="message"/></b></font></p>
    </html:messages>
    <div align="center">
    <fnac:bloc image="/images/recherche_off.gif" outlineImage="/images/pixel.gif" 
                      				rightShadingImage="/images/degrad_d_v1.gif" bottomShadingImage="/images/degrad_b_v1.gif" 
                      				cornerImage="/images/coin_degrad_v1.gif" titleStyleClass="fd_titre_bloc" 
                      				outlineStyleClass="tr_bloc" bodyStyleClass="BLOC">
     
    	<html:form action="/searchFull.do" onsubmit="return validateSearchFullForm(this);">
    	<html:hidden property="type"/>
    	<html:hidden property="autoAddToCart" value="false"/>
    	<table border="0" cellspacing="3" cellpadding="0" width="800px">
    		<tr align="center"> 
    			<td class="libelle1" colspan="4" align="right">Stock magasin ?&nbsp;<html:checkbox property="includeAllProduct"/></td>
    		</tr>
    		<tr align="center"> 
    			<td>&nbsp;</td>
    			<td><table border="0" cellspacing="1" cellpadding="0">
    				<tr>
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left"><b>ID Article (Réf. GU)<b></td>					
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left">Ean13 (ou Isbn) </td>
    					<td>&nbsp;</td>
    					<td>&nbsp;</td>
    					<td>&nbsp;</td>
    				</tr>
    				<tr>
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left"><html:text property="sku" onFocus="this.select();" onkeypress="checkEnter();" maxlength="30" size="20"/></td>					
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left"><html:text property="ean13" onFocus="this.select();" onkeypress="checkEnter();" maxlength="30" size="20"/></td>
    					<td>&nbsp;</td>
    					<td class="libelle1" align="right">
    						<logic:equal name="context" value="search">
    						<table border="0" cellspacing="0" cellpadding="0" class="button_action">
    							<tr>
    								<td><img src="images/pixel.gif" width="4" height="18"></td>
    								<td align="center" valign="middle">
    									<fnac:linkWithFormSubmit property="search" styleClass="action" page="/searchFull.do?autoAddToCart=true" onclick="return validateSearchFullForm(this);">
    					      				Mettre au panier
    					      			</fnac:linkWithFormSubmit>
    					      		</td>
    								<td><img src="images/pixel.gif" width="4" height="1"></td>
    							</tr>
    						</table>
    						</logic:equal>
    		      		</td>
    					<td>&nbsp;</td>
    				</tr>
    				</table>
    			</td>
    			<td>&nbsp;</td>
    		</tr>
    		<tr> 
    			<td colspan="3">&nbsp;</td>
    		</tr>
    		<tr> 
    			<td>&nbsp;</td>
    			<td><table border="0" cellspacing="1" cellpadding="0">
    				<tr>
    					<td width="10%" class="libelle1" align="left">Libellé Article</td>
    					<td width="37%" class="libelle1" align="left"><html:text property="title" maxlength="30" style="width:100%"/></td>
    					<td width="2%">&nbsp;</td>
    					<logic:notPresent name="headquarterMode" scope="session">
    						<td colspan="2"><html:hidden property="statusId"/></td>
    					</logic:notPresent>
    		    		<logic:present name="headquarterMode" scope="session">
    						<td width="10%" class="libelle1" align="left">Statut</td>
    						<td width="37%" class="libelle1" align="left">
    					    		<html:select property="statusId" style="width:100%">
    						         	<html:option value="-1">--------</html:option>
    						         	<html:options collection="status" property="id" labelproperty="label"/>
    						        </html:select>
    		        		</td>
    			        </logic:present>
    				</tr>
    				<tr>
    					<td width="10%" class="libelle1" align="left">Marque</td>
    					<td width="37%" class="libelle1" align="left"><html:text property="brand" maxlength="30" style="width:100%"/></td>
    					<td width="2%">&nbsp;</td>
     
    					<td class="libelle1" align="left">Type Opc</td>
    					<td class="libelle1" align="left">
    						<html:select property="opcTypeId" style="width:100%" onChange="javascript:refreshList('searchFullForm','opcId','/search/displayOpcList.do','opcTypeId',opcTypeId.value)">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="opcTypes" property="id" labelproperty="showLabel"/>
    				        </html:select>
    					</td>
     
     
     
    				</tr>
    				<tr>
    				<td class="libelle1" align="left">Nomenclature</td>
    					<td class="libelle1" align="left">
    						<html:select property="nomenclatureId" style="width:100%">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="nomenclatures" property="id" labelproperty="label"/>
    				        </html:select>
    					</td>
     
    					<td>&nbsp;</td>
     
    										<td class="libelle1" align="left">Opc</td>
    					<td class="libelle1" align="left">
    						<html:select property="opcId" style="width:100%">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="opcs" property="id" labelproperty="label"/>
    				        </html:select>
    					</td>									
    				</tr>
    				<tr>
    					<td class="libelle1" align="left">Propriété</td>
    					<td class="libelle1" align="left">
    						<html:text property="dynamicProperty" maxlength="60" size="60"/>
    					</td>
     
    					<td>&nbsp;</td>
     
    					<td class="libelle1" align="left">Signalétique</td>
    					<td class="libelle1" align="left">
    						<html:select property="identifyingId" style="width:100%">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="identifyings" property="id" labelproperty="showLabel"/>
    				        </html:select>
    					</td>										
    				</tr>
     
    				<tr>
     
     
    					<td width="10%" class="libelle1" align="left">N° de famille</td>
    					<td width="37%" class="libelle1" align="left"><html:text property="hierarchyCode" maxlength="4" size="10" onkeypress="return integerOnly();"/></td>
     
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left">Service</td>
    					<td class="libelle1" align="left">
    						<html:select property="serviceId" style="width:100%">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="services" property="id" labelproperty="showLabel" filter="false"/>
    				        </html:select>
    					</td>
    				</tr>
    				<tr>
     
    					<td class="libelle1" align="left">Gamme</td>
    					<td class="libelle1" align="left">
    						<html:select property="productRangeId" style="width:100%" onChange="javascript:refreshListAndSubList('searchFullForm','familyId','/search/displayClassificationList.do','productRangeId',productRangeId.value,'subFamilyId')">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="productRanges" property="id" labelproperty="showLabel"/>
    				        </html:select>
    	        		</td>
     
    					<td>&nbsp;</td>
     
    										<td class="libelle1" align="left">Crédit</td>
    					<td class="libelle1" align="left">
    						<html:select property="creditId" style="width:100%">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="credits" property="id" labelproperty="label"/>
    				        </html:select>
    					</td>
     
     
    				</tr>
    				<tr>
     
    					<td class="libelle1" align="left">Famille</td>
    					<td class="libelle1" align="left">
    						<html:select property="familyId" style="width:100%" onChange="javascript:refreshList('searchFullForm','subFamilyId','/search/displayClassificationList.do','familyId',familyId.value)">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="families" property="id" labelproperty="showLabel"/>
    				        </html:select>
    	        		</td>
     
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left">Vente ensemble</td>
    					<td class="libelle1" align="left">
    						<html:select property="compositeId">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:option value="1">Oui</html:option>
    				         	<html:option value="0">Non</html:option>
    				        </html:select>&nbsp;Bundle&nbsp;
    				        <html:select property="bundleId">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:option value="1">Oui</html:option>
    				         	<html:option value="0">Non</html:option>
    				        </html:select>
    	        		</td>
    				</tr>
     
    				<tr>					
     
    					<td class="libelle1" align="left">Sous-Famille</td>
    					<td class="libelle1" align="left">
    						<html:select property="subFamilyId" style="width:100%">
    				         	<html:option value="-1">--------</html:option>
    				         	<html:options collection="subFamilies" property="id" labelproperty="showLabel"/>
    				        </html:select>
    	        		</td>
     
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left">Date de vie min</td>
    					<td class="libelle1" align="left">
    						<html:text property="deadDateMin" maxlength="10" size="10"/>Date de vie max
    							<html:text property="deadDateMax" maxlength="10" size="10"/>
    					</td>
    				</tr>
     
    				<tr>
    					<td class="libelle1" align="left">Prix Entre</td>
    					<td class="libelle1" align="left">
    					<html:text property="priceMin" maxlength="10" size="10"/>&nbsp;et&nbsp; 
    					<html:text property="priceMax" maxlength="10" size="10"/>
    					</td>
    					<td>&nbsp;</td>
    					<td class="libelle1" align="left">Code collection</td>
    					<td class="libelle1" align="left">
    					<html:text property="productList" maxlength="1" size="1"/>
    					</td>
    				</tr>
    				</table>
    			</td>
    			<td>&nbsp;</td>
    		</tr>
    		<tr align="center"> 
    			<td>&nbsp;</td>
    			<td>
    				<table border="0" cellspacing="0" cellpadding="0">
    				<tr>
    					<td><img src="images/pixel.gif" width="4" height="18"></td>
    					<td align="center" valign="middle">
    						<table border="0" cellspacing="0" cellpadding="0" class="button_action">
    							<tr>
    								<td><img src="images/pixel.gif" width="4" height="18"></td>
    								<td align="center" valign="middle">
    									<fnac:linkWithFormSubmit property="search" styleClass="action" page="/searchFull.do?autoAddToCart=false" onclick="return validateSearchFullForm(this);">
    					      				Rechercher
    					      			</fnac:linkWithFormSubmit>
    					      		</td>
    								<td><img src="images/pixel.gif" width="4" height="1"></td>
    							</tr>
    						</table>
    					</td>
    					<td><img src="images/pixel.gif" width="4" height="1"></td>
    					    <td> 
     
    	        			</td>
    					    <td><img src="images/pixel.gif" width="10" height="1"></td>
    					    <td> 
     
    	        			</td>
            			<td><img src="images/pixel.gif" width="4" height="1"></td>
    					<logic:equal name="searchFullForm" property="type" value="searchSkuForBundle">
    						<td>
    							<table border="0" cellspacing="0" cellpadding="0" class="button_action">
    							<tr>
    								<td><img src="images/pixel.gif" width="4" height="18"></td>
    								<td align="center" valign="middle">
    									<fnac:linkWithFormSubmit property="search" styleClass="action" page="/displayBundle.do">
    					      				Retour au bundle
    					      			</fnac:linkWithFormSubmit>
    								</td>
    								<td><img src="images/pixel.gif" width="4" height="1"></td>
    							</tr>
    							</table>
    						</td>
    					</logic:equal>
    					<td><img src="images/pixel.gif" width="4" height="1"></td>
    				</tr>
    				</table>
    			</td>
    			<td>&nbsp;</td>
    		</tr>		
    	</table>
    	</html:form>
     
    	<html:javascript formName="searchFullForm"/>
    </fnac:bloc>
     
    <logic:present name="items">
    	<logic:equal name="context" value="search">
    		<html:form action="/addToCart.do" method="post">
    		<%@ include file="/search/searchResult.jsp" %>
    		</html:form>
    	</logic:equal>
    	<logic:equal name="context" value="bundleArticle">
    		<%@ include file="/search/searchResult.jsp" %>
    	</logic:equal>
    </logic:present>
     
    </div>
    Si quelqu'un a une idée, merci d'avance...

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

    Informations forums :
    Inscription : Juillet 2006
    Messages : 165
    Par défaut
    c'est normal, il y a 2 submits qui sont effectués:
    1 pour le submit "normal" qui s'effectue par défaut quand tu appuie sur enter quand tu es dans un des champs du formulaire.
    1 pour le submit que tu as ajouté dans ta fonction javascript checkEnter()

    Vire donc ce dernier...

Discussions similaires

  1. l'even CheckedChanged se lance deux fois pour un radiobouton
    Par aiglelibre dans le forum Développement Windows
    Réponses: 2
    Dernier message: 07/06/2013, 23h58
  2. Une action executée deux fois
    Par aelmalki dans le forum Struts 1
    Réponses: 1
    Dernier message: 31/07/2010, 21h22
  3. Lire deux fois un inputstream
    Par Guybrush dans le forum Entrée/Sortie
    Réponses: 6
    Dernier message: 05/09/2005, 14h50
  4. Réponses: 14
    Dernier message: 30/03/2005, 21h50
  5. Sélectionner un même enregistrement deux fois...
    Par Manu0086 dans le forum Langage SQL
    Réponses: 11
    Dernier message: 02/02/2004, 13h09

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