Bonsoir;
j'utilise jsf avec primefaces,je veux ajouter du javascript pour rendre des selectBooleanCheckbox comme des radio bouton
voilà ma page
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
 
<?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>
</h:head>
 
 
	<h:body>
	<h:outputScript library="js" name="checkbox.js" />
 
							<!-- 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>
</h:form>
 
</h:body>
</html>
mon fichier checkbox.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
$("selectBooleanCheckbox").click(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);
    }
});
Merci d'avance