Ajouter du javascript à une page .jsf
salut tout le monde,j'ai déjà posté ce message dans le forum de jsf mais jusqu'à maintenant j'ai pas reçu de solution à mon problème.
je veux que mes checkboxs auront la même utilisation que les radioButtons en utilisant javaScript ,pouvez me dire si mon code javaScript est correcte ,merci d'avance.
ma page jsf:
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 45 46 47 48 49 50 51 52
|
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
<script >
$("selectBooleanCheckbox").onchange(function() {
if ($(this).is(":checked")) {
var group = "selectBooleanCheckbox[name='" + $(this).attr("name") + "']";
$(group).prop("checked", false);
$(this).prop("checked", true);
} else {
$(this).prop("checked", false);
}
});
</script>
</h:head>
<h:body>
<!-- ENTETE -->
<form >
<p:selectBooleanCheckbox name="A">1
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="A">2
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="A">3
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="A">4
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="B">1
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="B">2
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="B">3
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="B">4
</p:selectBooleanCheckbox>
</h:form>
</h:body>
</html> |