use of sqlite.feature.contentprovider.kripton35.entities.Person in project ConsoElectric by anakkarsara.
the class DeletePerson method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h2><a href=\"index.html\">Retour page d'acueil</a></h2>");
out.println("<FORM Method=\"POST\" Action=\"/DeletePerson\">\r\n" + " <table border = 1 cellpadding = \"10\" align = \"center\">\r\n");
out.println("<td>Proprietaire</td><td><SELECT name=\"personToDelete\" size=\"5\">");
for (Person p : pd.allPersons()) {
out.println("<option value = \"" + p.getId() + "\">" + p.getFirstName() + " " + p.getFamilyName() + "</option>");
}
out.println(" </td></tr><tr ><td colspan = \"2\" align = \"right\"><INPUT type=submit value=Send></td>\r\n");
out.println(" </table>\r\n" + " </FORM>");
}
use of sqlite.feature.contentprovider.kripton35.entities.Person in project ConsoElectric by anakkarsara.
the class DeletePerson method doPost.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("dev");
EntityManager manager = factory.createEntityManager();
EntityTransaction tx = manager.getTransaction();
tx.begin();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
PersonDao pd = new PersonDao();
pd.deleteById(Long.parseLong(request.getParameter("personToDelete")));
tx.commit();
out.println("<h2><a href=\"index.html\">Retour page d'acueil</a></h2>");
out.println("<table border = 2 cellpadding = \"10\" cellspacing = \"10\" align= \"center\"> <tr> <th>Prenom</th> <th>Nom</th> <th>Email</th> ");
DAO test = new DAO(manager);
for (Person next : test.listPersons()) {
out.println(" <tr> <td>" + next.getFirstName() + "</td> <td>" + next.getFamilyName() + "</td> <td>" + next.getMail() + "</td> </tr> ");
}
out.println("</table> ");
manager.close();
}
Aggregations