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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
public class RechercheBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<Personne> maListe, listeResult;
private String nom, prenom;
public RechercheBean()
{
Personne.setCpt(0);
maListe = new ArrayList<Personne>();
this.maListe.add(new Personne("Barry","Catherine"));
this.maListe.add(new Personne("Bosch","Jérome"));
this.maListe.add(new Personne("Boutilier","Xavier"));
this.maListe.add(new Personne("Lazure","Dominique"));
this.maListe.add(new Personne("Leclet","Dominique"));
this.maListe.add(new Personne("Pau","Audrey"));
this.maListe.add(new Personne("Irastorza","Isabel"));
this.maListe.add(new Personne("Barry","Catherine"));
this.maListe.add(new Personne("Perin","Mick"));
this.maListe.add(new Personne("Pécant","Nicolas"));
this.maListe.add(new Personne("Meunier","Véronique"));
this.maListe.add(new Personne("Furst","frédéric"));
this.maListe.add(new Personne("Fortet","Stéphane"));
this.maListe.add(new Personne("Mioupau","Frédéric"));
this.maListe.add(new Personne("Djouambi","Chemsédine"));
this.maListe.add(new Personne("Bernard","Damien"));
this.maListe.add(new Personne("Joirons","Céline"));
this.maListe.add(new Personne("Lapujade","Anne"));
this.maListe.add(new Personne("Cormier","Christian"));
this.maListe.add(new Personne("Ducay","Stéphane"));
}
public String search() {
listeResult = new ArrayList<Personne>();
Iterator<Personne> ite = maListe.iterator();
Personne p = new Personne();
int pNom;
int pPrenom;
while(ite.hasNext())
{
p = ite.next();
pNom = p.getNom().indexOf(this.nom);
pPrenom = p.getPrenom().indexOf(this.prenom);
if(this.nom == "" && this.prenom == "")
{
listeResult.add(p);
System.out.println("Les deux sont vide !!!");
}
else
{
if(this.nom != "" && this.prenom == "" && pNom >= 0)
{
listeResult.add(p);
System.out.println("Le prénom est vide !!!");
System.out.println(p.getNom());
}
else
{
if(this.nom == "" && this.prenom != "" && pPrenom >=0)
{
listeResult.add(p);
System.out.println("Le nom est vide !!!");
System.out.println(p.getPrenom());
}
else
{
if(this.nom != "" && this.prenom != "" && (pNom >=0 || pPrenom >= 0))
{
listeResult.add(p);
System.out.println("Le nom et le prénom sont renseigné !!!");
System.out.println(p.getPrenom() + " " + p.getNom());
}
}
}
}
}
return ("Page2");
}
public String Back()
{
return ("Page1");
}
/*******************************************************************************************
****************************** Accesseur de la class ************************************
******************************************************************************************/
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public List<Personne> getListeResult() {
return listeResult;
}
public void setListeResult(List<Personne> listeResult) {
this.listeResult = listeResult;
}
} |
Partager