-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controlleur.java
81 lines (60 loc) · 2.52 KB
/
Controlleur.java
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
package fasoyaar.vue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fasoyaar.entity.categorie.Article;
import com.fasoyaar.entity.client.Adresse;
import com.fasoyaar.entity.client.Client;
import com.fasoyaar.entity.commande.Commande;
import com.fasoyaar.entity.commande.LigneCmd;
import com.fasoyaar.session.catalogue.ICatalogueLocal;
import com.fasoyaar.session.client.IClientLocal;
import com.fasoyaar.session.commande.ICommandeLocal;
@WebServlet(name="controlleur",urlPatterns={"/controlleur"})
public class Controlleur extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
@EJB
private IClientLocal metier;
@EJB
private ICommandeLocal commande;
@EJB
private ICatalogueLocal catalogue;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Client> clts=(ArrayList<Client>)metier.getAllClients();
//Commande cmd = commande.getCommande((Client)clts[1]);
//commande.deleteCommande(cmd);
request.setAttribute("clients", clts);
request.getRequestDispatcher("client.jsp").forward(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String nom=request.getParameter("nom");
String prenom=request.getParameter("prenom");
String login=request.getParameter("login");
String email=request.getParameter("email");
String password=request.getParameter("password");
String ville=request.getParameter("ville");
String pays=request.getParameter("pays");
String telephone=request.getParameter("telephone");
String idClient=request.getParameter("id");
Adresse a= new Adresse(ville, "", pays);
if(!nom.isEmpty() && !prenom.isEmpty() && !login.isEmpty() && !email.isEmpty() && !password.isEmpty()){
Client cl=metier.createClient(new Client(nom, prenom, telephone, password,email, login,new Date()),a);
//commande.deleteCommande(commande.getCommande(cl));
//commande.createCommande(cl,commande.createLigneCommande(2, new Article()) );
//commande.getCommande(cl);
}
doGet(request, response);
}
}