Bonjour,

voilà j'ai un petit soucis.

je veux lorsque choisir un nom il m'affiche leur matricule dans inputText, le probleme dans la methode onCountryChange comment je peux recupere le matricule qui est dans le list

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
 
 
import java.io.Serializable;
import java.util.*;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.*;
import javax.faces.model.SelectItem;
 
@ManagedBean(name = "dropdownView")
@ViewScoped
public class UserBean implements Serializable {
 
    private Personne p;
    private int a;
    private List<Personne> l;
    private List<SelectItem> selectItem;
 
    @PostConstruct
    public void init() {
        l = new ArrayList<Personne>();
        l.add(new Personne(123, "a"));
        l.add(new Personne(124, "b"));
        l.add(new Personne(125, "c"));
        l.add(new Personne(126, "d"));
        p = new Personne();
    }
 
    public List<SelectItem> getSelectItem() {
        this.selectItem = new ArrayList<SelectItem>();
        for (Personne c : l) {
            SelectItem s = new SelectItem(c.getMat(), c.getNom());
            this.selectItem.add(s);
        }
        return selectItem;
    }
 
    public void onCountryChange() {
        if (p.getNom() != null && !p.getNom().equals("")) {
 
        } else {
 
        }
    }
 
    public void setSelectItem(List<SelectItem> selectItem) {
        this.selectItem = selectItem;
    }
 
    public List<Personne> getL() {
        return l;
    }
 
    public void setL(List<Personne> l) {
        this.l = l;
    }
 
    public Personne getP() {
        return p;
    }
 
    public void setP(Personne p) {
        this.p = p;
    }
 
    public int getA() {
        return a;
    }
 
    public void setA(int a) {
        this.a = a;
    }
 
}
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
 
<h:form>
            <p:growl id="msgs" showDetail="true" />
 
            <p:panel style="margin-bottom:10px;">
                <h:panelGrid columns="2" cellpadding="5">
 
                    <p:outputLabel for="nom" value="Nom: " />
                    <p:selectOneMenu id="nom" value="#{dropdownView.p.nom}" style="width:150px">
                        <p:ajax listener="#{dropdownView.onCountryChange}" update="Mat" /> 
                        <f:selectItem itemLabel="Select Nom" itemValue="" noSelectionOption="true" />
                        <f:selectItems value="#{dropdownView.selectItem}" />
                    </p:selectOneMenu>
 
 
                     <p:outputLabel for="Mat" value="Matricule: " />
                     <p:inputText id="Mat" value="#{dropdownView.a}" disabled="true" style="width:140px"/>
 
                </h:panelGrid>
            </p:panel>
        </h:form>
Merci pour votre aide.