bonjour,
je cherche le moyen de crée des racourci clavier pour pouvoir changer le radio button sélectionné, j'ai penser a utiliser un <rich:hotKey />
mais ca ne fonctionne pas ...
la partie sensé crée les racourci ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <h:form id="gestionEcran" ><rich:panel> <h:selectOneRadio id="radio"> <f:selectItem itemLabel="choix0" itemValue="0" /> <f:selectItem itemLabel="choix1" itemValue="1" /> </h:selectOneRadio> </rich:panel> </h:form>
le code java scripte coréspendant ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <a4j:loadScript src="/WEB-INF/js/check-radio-obj.js" /> <rich:hotKey key="ctrl+up" handler="setCheckedValue(document.forms['gestionEcran'].elements['radio'],'0');" /> <rich:hotKey key="ctrl+down" handler="setCheckedValue(document.forms['gestionEcran'].elements['radio'],'1');" />
je tourne en rond ,j'ai essayer la place de document.forms['gestionEcran'].elements['radio'] les méthodes de rich du lien
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 // source : http://www.somacon.com/p143.php // return the value of the radio button that is checked // return an empty string if none are checked, or // there are no radio buttons function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } // set the radio button with the given value as being checked // do nothing if there are no radio buttons // if the given value does not exist, all the radio buttons // are reset to unchecked function setCheckedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } }
Partager