Merci pour votre aide mais j'ai encore du problème lorsque je mis
var obj = document.getElementById("MyForm:nbClicBouton");
ça génère une erreur :
1 2 3 4
| Multiple annotations found at this line:
- Unreachable code
- Type mismatch: cannot convert from Element to
___obj0 |
voilà mon code:
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
| <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<f:view >
<h:form id="MyForm" style="background-color: CornflowerBlue; width: 1254px">
<h:panelGrid border="0" columns="8" style="width: 365px; height: 100px">
<h4><h:outputText value="Nom" style="width: 65px; height: 20px"></h:outputText></h4>
<h:inputText id="nomDestinataire" disabled="true" value="#{envoi.nomDest}" style="width: 151px; height: 30px"></h:inputText>
<h4><h:outputText value="Prénom" style="width: 65px; height: 30px"></h:outputText></h4>
<h:inputText id="prenomDestinataire" disabled="true" value="#{envoi.prenomDest}" style="width: 151px; height: 30px"></h:inputText>
<h4><h:outputText value="Tél" style="width: 65px; height: 30px"></h:outputText></h4>
<h:inputText id="telDestinataire" disabled="true" value="#{envoi.telDest}" style="width: 151px; height: 30px"></h:inputText>
</h:panelGrid><br>
<h:panelGrid border="0" columns="3" style="width: 648px;height: 40px;">
<input type="hidden" id="nbClicBouton" value="0"/>
<h:commandButton value="Ajouter destinataire" action="#{envoi.boutonActionDest}" onclick="return testBtn();" style="width: 160px"> </h:commandButton>
</h:panelGrid>
</h:form>
</f:view>
<script type="text/javascript">
function testBtn() {
var obj = document.getElementById("MyForm:nbClicBouton");
if (obj.value == "0") {
// Premier clic sur le bouton...
document.getElementById("MyForm:nomDestinataire").disabled = false;
document.getElementById("MyForm:prenomDestinataire").disabled = false;
document.getElementById("MyForm:telDestinataire").disabled = false;
obj.value = "1";
// En retournant false, le onclick du commandButton retournera lui-même false, et le bouton n'enverra rien au serveur, et donc l'action au niveau du bean ne sera pas exécutée...
return false;
}
// Le bouton a déjà été cliqué.
// En retournant true, le onclick du commandButton retournera lui-même true, et le bouton enverra la requête au serveur, et donc l'action au niveau du bean sera exécutée...
return true;
}
</script>
</html> |
Merci d'avance
Partager