diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/artifacts/agenda_war.xml b/.idea/artifacts/agenda_war.xml new file mode 100644 index 0000000..c1d450b --- /dev/null +++ b/.idea/artifacts/agenda_war.xml @@ -0,0 +1,14 @@ + + + $PROJECT_DIR$/target + + + agenda + war + + + + + + + \ No newline at end of file diff --git a/.idea/artifacts/agenda_war_exploded.xml b/.idea/artifacts/agenda_war_exploded.xml new file mode 100644 index 0000000..f3f28a7 --- /dev/null +++ b/.idea/artifacts/agenda_war_exploded.xml @@ -0,0 +1,26 @@ + + + $PROJECT_DIR$/target/agenda-1.0-SNAPSHOT + + + true + agenda + war + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..81670f0 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_sun_mail_javax_mail_1_6_2.xml b/.idea/libraries/Maven__com_sun_mail_javax_mail_1_6_2.xml new file mode 100644 index 0000000..f5980e4 --- /dev/null +++ b/.idea/libraries/Maven__com_sun_mail_javax_mail_1_6_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_activation_activation_1_1.xml b/.idea/libraries/Maven__javax_activation_activation_1_1.xml new file mode 100644 index 0000000..180d587 --- /dev/null +++ b/.idea/libraries/Maven__javax_activation_activation_1_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_javaee_api_8_0_1.xml b/.idea/libraries/Maven__javax_javaee_api_8_0_1.xml new file mode 100644 index 0000000..1ce58d5 --- /dev/null +++ b/.idea/libraries/Maven__javax_javaee_api_8_0_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_mvc_javax_mvc_api_1_0_0.xml b/.idea/libraries/Maven__javax_mvc_javax_mvc_api_1_0_0.xml new file mode 100644 index 0000000..97011b8 --- /dev/null +++ b/.idea/libraries/Maven__javax_mvc_javax_mvc_api_1_0_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml new file mode 100644 index 0000000..f854ab0 --- /dev/null +++ b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_7_1.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_7_1.xml new file mode 100644 index 0000000..cbbc09f --- /dev/null +++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_7_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_7_1.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_7_1.xml new file mode 100644 index 0000000..f17fef7 --- /dev/null +++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_7_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_7_1.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_7_1.xml new file mode 100644 index 0000000..1ded6d5 --- /dev/null +++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_7_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_7_1.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_7_1.xml new file mode 100644 index 0000000..983d973 --- /dev/null +++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_7_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml new file mode 100644 index 0000000..fbc1b16 --- /dev/null +++ b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/itextpdf_5_5_13_2.xml b/.idea/libraries/itextpdf_5_5_13_2.xml new file mode 100644 index 0000000..4f37168 --- /dev/null +++ b/.idea/libraries/itextpdf_5_5_13_2.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/mysql_connector_java_8_0_20.xml b/.idea/libraries/mysql_connector_java_8_0_20.xml new file mode 100644 index 0000000..44db066 --- /dev/null +++ b/.idea/libraries/mysql_connector_java_8_0_20.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2542fe4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..55f3baa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/agenda.iml b/agenda.iml new file mode 100644 index 0000000..aace347 --- /dev/null +++ b/agenda.iml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..dc03db6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + com + agenda + 1.0-SNAPSHOT + agenda + war + + + 1.8 + 1.8 + 5.7.1 + + + + + javax + javaee-api + 8.0.1 + provided + + + javax.mvc + javax.mvc-api + 1.0.0 + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.1 + + + + \ No newline at end of file diff --git a/src/main/java/controller/Controller.java b/src/main/java/controller/Controller.java new file mode 100644 index 0000000..766c7fd --- /dev/null +++ b/src/main/java/controller/Controller.java @@ -0,0 +1,208 @@ +package controller; + +import java.io.IOException; +import java.util.ArrayList; + +import javax.servlet.RequestDispatcher; +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.itextpdf.text.Document; +import com.itextpdf.text.Paragraph; +import com.itextpdf.text.pdf.PdfPCell; +import com.itextpdf.text.pdf.PdfPTable; +import com.itextpdf.text.pdf.PdfWriter; + +import model.DAO; +import model.JavaBeans; + +//urlPatterns: define as URLs que serão utilizadas para acessar a Servlet +@WebServlet(urlPatterns = { "/Controller", "/main", "/insert", "/select", "/delete", "/update", "/report" }) +public class Controller extends HttpServlet { + + private static final long serialVersionUID = 1L; + DAO dao = new DAO(); + JavaBeans contato = new JavaBeans(); + + public Controller() { + super(); + + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + String action = request.getServletPath(); + System.out.println(action); + + if (action.equals("/main")) { + contatos(request, response); + + } else if (action.equals("/insert")) { + novoContato(request, response); + + } else if (action.equals("/select")) { + listarContato(request, response); + + } else if (action.equals("/update")) { + editarContato(request, response); + + } else if (action.equals("/delete")) { + deletarContato(request, response); + + } else if (action.equals("/report")) { + gerarRelatorio(request, response); + + } else { + response.sendRedirect("index.html"); + } + } + + // Listar contatos + protected void contatos(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Criando um objeto que irá receber os dados JavaBeans + ArrayList lista = dao.listarContatos(); + + // Encaminhar a lista ao documento agenda.jsp + request.setAttribute("contatos", lista); + RequestDispatcher rd = request.getRequestDispatcher("agenda.jsp"); + rd.forward(request, response); + } + + protected void novoContato(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // setando as variaveis JavaBeans + contato.setNome(request.getParameter("nome")); + contato.setFone(request.getParameter("fone")); + contato.setEmail(request.getParameter("email")); + + // invocar o metodo inserirContato passando o objeto contato + dao.inserirContato(contato); + + // redirecionar para o documento agenda.jsp + response.sendRedirect("main"); + } + + // editar contato + protected void listarContato(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Recebimento do id do contato que será editado + String idcon = request.getParameter("idcon"); + // System.out.println(idcon); + + // Setar a variável JavaBeans + contato.setIdcon(idcon); + + // executar o método selecionarContato + dao.selecionarContato(contato); + + // setar os atributos do formulário com o conteudo JavaBeans + request.setAttribute("idcon", contato.getIdcon()); + request.setAttribute("nome", contato.getNome()); + request.setAttribute("fone", contato.getFone()); + request.setAttribute("email", contato.getEmail()); + + // encaminhar ao documento editar.jsp + RequestDispatcher rd = request.getRequestDispatcher("editar.jsp"); + rd.forward(request, response); + } + + protected void editarContato(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // setar as variáveis JavaBeans + contato.setIdcon(request.getParameter("idcon")); + contato.setNome(request.getParameter("nome")); + contato.setFone(request.getParameter("fone")); + contato.setEmail(request.getParameter("email")); + + // testar + System.out.println(request.getParameter("idcon")); + System.out.println(request.getParameter("nome")); + System.out.println(request.getParameter("fone")); + System.out.println(request.getParameter("email")); + + // executar o método alterarContato + dao.alterarContato(contato); + + // redirecionar para o docmuento agenda.jsp (atualizando as alterações) + response.sendRedirect("main"); + } + + // deletar contato + protected void deletarContato(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Recebimento do id do contato que será deletado + String idcon = request.getParameter("idcon"); + + System.out.println(request.getParameter("idcon")); + + contato.setIdcon(idcon); + + // executar o método deletarContato + dao.deletarContato(contato); + + // redirecionar para o docmuento agenda.jsp (atualizando as alterações) + response.sendRedirect("main"); + } + + // gerar relatório + protected void gerarRelatorio(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + Document documento = new Document(); + try { + + //tipo de conteúdo + response.setContentType("apllication/pdf"); + + //nome do documento + response.addHeader("Content-Disposition", "inline; filename=" + "contatos.pdf"); + + //criar documento + PdfWriter.getInstance(documento, response.getOutputStream()); + + //abrir o documento + documento.open(); + documento.add(new Paragraph("Lista de Contatos:")); + documento.add(new Paragraph(" ")); + + //criar tabela + PdfPTable tabela = new PdfPTable(3); + + //cabeçalho + PdfPCell col1 = new PdfPCell(new Paragraph("Nome")); + PdfPCell col2 = new PdfPCell(new Paragraph("Telefone")); + PdfPCell col3 = new PdfPCell(new Paragraph("E-mail")); + + tabela.addCell(col1); + tabela.addCell(col2); + tabela.addCell(col3); + + //popupar a tabela com os contatos + ArrayList lista = dao.listarContatos(); + for(int i=0; i < lista.size(); i++) { + tabela.addCell(lista.get(i).getNome()); + tabela.addCell(lista.get(i).getFone()); + tabela.addCell(lista.get(i).getEmail()); + } + + documento.add(tabela); + + documento.close(); + + } catch (Exception e) { + System.out.println(e); + documento.close(); + } + + } +} diff --git a/src/main/java/model/DAO.java b/src/main/java/model/DAO.java new file mode 100644 index 0000000..d8027b2 --- /dev/null +++ b/src/main/java/model/DAO.java @@ -0,0 +1,176 @@ +package model; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; + +public class DAO { + + /** M�dulo de conex�o **/ + + // Par�metros de conex�o + private String driver = "com.mysql.cj.jdbc.Driver"; + private String url = "jdbc:mysql://127.0.0.1:3306/dbagenda?useTimezone=true&serverTimezone=UTC"; + private String user = "root"; + private String password = "Dba@123"; + + // M�todo de conex�o + private Connection conectar() { + Connection con = null; + try { + Class.forName(driver); + con = DriverManager.getConnection(url, user, password); + return con; + } catch (Exception e) { + System.out.println(e); + return null; + } + } + + /* CRUD CREATE */ + public void inserirContato(JavaBeans contato) { + String create = "insert into contatos(nome,fone,email) values (?,?,?)"; + try { + // abrindo conex�o com o BD + Connection con = conectar(); + + // preparar a query para execu��o no bd + PreparedStatement pst = con.prepareStatement(create); + + // Substituir os par�metros (?) pelo conte�do das vari�veis das vari�veis + // JavaBeans + pst.setString(1, contato.getNome()); + pst.setString(2, contato.getFone()); + pst.setString(3, contato.getEmail()); + + // executar a query + pst.executeUpdate(); + + // encerrar a conex�o com o BD + con.close(); + + } catch (Exception e) { + System.out.println(e); + } + } + + /* CRUD READ */ + + public ArrayList listarContatos() { + + // Criando um objeto para acessar a classe JavaBeans + ArrayList contatos = new ArrayList<>(); + String read = "select * from contatos order by nome"; + + try { + Connection con = conectar(); + PreparedStatement pst = con.prepareStatement(read); + ResultSet rs = pst.executeQuery(); + + // executado enquanto houver contatos + while (rs.next()) { + + // variaveis de apoio que recebem os dados do banco + String idcon = rs.getString(1); + String nome = rs.getString(2); + String fone = rs.getString(3); + String email = rs.getString(4); + + // populando o ArrayList + contatos.add(new JavaBeans(idcon, nome, fone, email)); + } + con.close(); + return contatos; + + } catch (Exception e) { + System.out.println(e); + return null; + } + } + + /* CRUD UPDATE */ + // selecionar o contato + public void selecionarContato(JavaBeans contato) { + String read2 = "select * from contatos where idcon=?"; + + try { + Connection con = conectar(); + PreparedStatement pst = con.prepareStatement(read2); + pst.setString(1, contato.getIdcon()); + ResultSet rs = pst.executeQuery(); + + while (rs.next()) { + + // setar as vari�veis JavaBeans + contato.setIdcon(rs.getString(1)); + contato.setNome(rs.getString(2)); + contato.setFone(rs.getString(3)); + contato.setEmail(rs.getString(4)); + + } + con.close(); + + } catch (Exception e) { + System.out.println(e); + } + } + + // alterar contato + public void alterarContato(JavaBeans contato) { + + String create = "update contatos set nome=?, fone=?, email=? where idcon=?"; + + try { + Connection con = conectar(); + PreparedStatement pst = con.prepareStatement(create); + pst.setString(1, contato.getNome()); + pst.setString(2, contato.getFone()); + pst.setString(3, contato.getEmail()); + pst.setString(4, contato.getIdcon()); + + // executar a query + pst.executeUpdate(); + + // encerrar a conex�o com o BD + con.close(); + + } catch (Exception e) { + System.out.println(e); + } + } + + /* CRUD DELETAR */ + public void deletarContato(JavaBeans contato) { + + String delete = "delete from contatos where idcon=?"; + + try { + Connection con = conectar(); + PreparedStatement pst = con.prepareStatement(delete); + pst.setString(1, contato.getIdcon()); + + // executar a query + pst.executeUpdate(); + + // encerrar a conex�o com o BD + con.close(); + + } catch (Exception e) { + System.out.println(e); + } + } + + // teste de conex�o + +// public void testeConexao() { +// try { +// Connection con = conectar(); +// System.out.println(con); +// con.close(); +// } catch (Exception e) { +// System.out.println(e); +// } +// } +} diff --git a/src/main/java/model/JavaBeans.java b/src/main/java/model/JavaBeans.java new file mode 100644 index 0000000..71eff5a --- /dev/null +++ b/src/main/java/model/JavaBeans.java @@ -0,0 +1,58 @@ +package model; + +public class JavaBeans { + + private String idcon; + private String nome; + private String fone; + private String email; + + // construtores + + public JavaBeans() { + super(); + } + + public JavaBeans(String idcon, String nome, String fone, String email) { + super(); + this.idcon = idcon; + this.nome = nome; + this.fone = fone; + this.email = email; + } + + // encapsulamento + + public String getIdcon() { + return idcon; + } + + public void setIdcon(String idcon) { + this.idcon = idcon; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public String getFone() { + return fone; + } + + public void setFone(String fone) { + this.fone = fone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + +} diff --git a/src/main/resources/META-INF/beans.xml b/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..6f34698 --- /dev/null +++ b/src/main/resources/META-INF/beans.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..625444a --- /dev/null +++ b/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/src/main/webapp/WEB-INF/lib/itextpdf-5.5.13.2.jar b/src/main/webapp/WEB-INF/lib/itextpdf-5.5.13.2.jar new file mode 100644 index 0000000..dee1be8 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/itextpdf-5.5.13.2.jar differ diff --git a/src/main/webapp/WEB-INF/lib/mysql-connector-java-8.0.20.jar b/src/main/webapp/WEB-INF/lib/mysql-connector-java-8.0.20.jar new file mode 100644 index 0000000..f4bd739 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/mysql-connector-java-8.0.20.jar differ diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f6c358b --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + agenda + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + \ No newline at end of file diff --git a/src/main/webapp/agenda.jsp b/src/main/webapp/agenda.jsp new file mode 100644 index 0000000..f81f633 --- /dev/null +++ b/src/main/webapp/agenda.jsp @@ -0,0 +1,62 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ page import="model.JavaBeans"%> +<%@ page import="java.util.ArrayList"%> + +<% +@ SuppressWarnings ("unchecked") +ArrayList lista = (ArrayList) request.getAttribute("contatos"); +%> + + + + + +Agenda de contatos + + + + +
+
+

Agenda de contatos

+
+ +
+ + + + + + + + + + + + <% + for (int i = 0; i < lista.size(); i++) { + %> + + + + + + + + <% + } + %> + +
IdNomeTelefoneEmailOpções
<%=lista.get(i).getIdcon()%><%=lista.get(i).getNome()%><%=lista.get(i).getFone()%><%=lista.get(i).getEmail()%>
+ + + \ No newline at end of file diff --git a/src/main/webapp/editar.jsp b/src/main/webapp/editar.jsp new file mode 100644 index 0000000..72e12aa --- /dev/null +++ b/src/main/webapp/editar.jsp @@ -0,0 +1,38 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ page import="model.JavaBeans"%> + + + + + +Agenda + + + + +
+

Editar contato

+
+
+ + + + + + + + + + + + + + + +
">
">
">
">
+ +
+ + + \ No newline at end of file diff --git a/src/main/webapp/imagens/agenda.png b/src/main/webapp/imagens/agenda.png new file mode 100644 index 0000000..3d86cc8 Binary files /dev/null and b/src/main/webapp/imagens/agenda.png differ diff --git a/src/main/webapp/imagens/favicon.svg b/src/main/webapp/imagens/favicon.svg new file mode 100644 index 0000000..4ff0308 --- /dev/null +++ b/src/main/webapp/imagens/favicon.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html new file mode 100644 index 0000000..cd40383 --- /dev/null +++ b/src/main/webapp/index.html @@ -0,0 +1,17 @@ + + + + +Agenda + + + + +
+ +

Agenda de Contatos

+ Acessar +
+ + \ No newline at end of file diff --git a/src/main/webapp/novo.html b/src/main/webapp/novo.html new file mode 100644 index 0000000..304c596 --- /dev/null +++ b/src/main/webapp/novo.html @@ -0,0 +1,31 @@ + + + + +Agenda + + + + +
+

Criar novo contato

+
+
+ + + + + + + + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/src/main/webapp/scripts/confirmador.js b/src/main/webapp/scripts/confirmador.js new file mode 100644 index 0000000..4e842de --- /dev/null +++ b/src/main/webapp/scripts/confirmador.js @@ -0,0 +1,14 @@ +/** + * Validacao de Exclusao + * @author Andressa Silva + * @param idcon + */ + +function confirmar(idcon){ + let resposta = confirm("Confirma a exclusão deste contato?") + if(resposta === true){ + + //encaminhando o parametro idcon para controller + window.location.href = "delete?idcon=" + idcon + } +} \ No newline at end of file diff --git a/src/main/webapp/scripts/validador.js b/src/main/webapp/scripts/validador.js new file mode 100644 index 0000000..742df44 --- /dev/null +++ b/src/main/webapp/scripts/validador.js @@ -0,0 +1,23 @@ +/** + * Validação de Formulário + * @author Andressa Silva + */ + +function validar() { + let nome = frmContato.nome.value + let fone = frmContato.fone.value + if (nome === "") { + alert('Preencha o campo Nome') + frmContato.nome.focus() + return false + + }else if(fone === "") { + alert('Preencha o campo Telefone') + frmContato.fone.focus() + return false + + }else { + document.forms["frmContato"].submit() + } +} + diff --git a/src/main/webapp/style.css b/src/main/webapp/style.css new file mode 100644 index 0000000..12ad27a --- /dev/null +++ b/src/main/webapp/style.css @@ -0,0 +1,180 @@ +@charset "utf-8"; + +@import + url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap') + ; + +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + font-family: 'Roboto', sans-serif; + font-size: 1em; + font-weight: 400; +} + +.inicio { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +.agenda { + display: flex; + flex-direction: column; +} + +img { + margin-top: 20px; + margin-left: auto; + margin-right: auto; + width: 50%; +} + +.titulo { + margin-left: 20px; + margin-bottom: 20px; +} + +.borda-embaixo { + border-style: solid; + border-width: 0 0 5px 0; + border-color: #2E186A; +} + +h1 { + color: #2E186A; + margin-top: 20px; + font-size: 1.6em; +} + +.Botao1 { + font-size: 1em; + font-weight: 700; + color: #fff; + text-decoration: none; + background-color: #FE7624; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + border: 0; + cursor: pointer; +} + +.Botao4 { + font-size: 1em; + font-weight: 700; + color: #fff; + text-decoration: none; + background-color: #2E186A; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + border: 0; + cursor: pointer; + margin-left: 10px; +} + +nav { + padding: 10px; + justify-content: space-between; +} + +.navprincipal { + padding: 0; + margin-top: 30px; + margin-bottom: 16px; +} + +.BotaoAlterar { + font-weight: 500; + font-size: 1em; + color: #fff; + text-decoration: none; + background-color: #FE7624; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + border: 0; + cursor: pointer; +} + +.BotaoDeletar { + font-size: 1em; + font-weight: 500; + color: #fff; + text-decoration: none; + background-color: #e32636; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + margin-left: 10px; + border: 0; + cursor: pointer; +} + +.agenda .Botao1 { + margin-left: 20px; + background-color: #228b22; +} + +form { + margin-top: 20px; + margin-left: 20px; +} + +.Caixa1 { + width: 320px; + padding: 5px; + margin-bottom: 10px; + border: 1px solid #2E186A; + border-radius: 5px; +} + +.Caixa2 { + padding: 5px; + margin-bottom: 10px; + border: 1px solid #2E186A; + border-radius: 5px; +} + +#Caixa3 { + padding: 5px; + margin-bottom: 10px; + border: 1px solid #FE7624; + border-radius: 5px; + display: none; +} + +#tabela { + margin-left: 20px; + margin-top: 20px; + border-collapse: collapse; + color: #2E186A; + font-size: 1.1em; +} + +#tabela th { + border: 1px solid #2E186A; + padding: 10px; + text-align: left; + background-color: #2E186A; + color: #fff; +} + +#tabela td { + border: 1px solid #2E186A; + padding: 10px; +} \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/META-INF/MANIFEST.MF b/target/agenda-1.0-SNAPSHOT/META-INF/MANIFEST.MF new file mode 100644 index 0000000..08135b1 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Created-By: IntelliJ IDEA +Built-By: dessa +Build-Jdk: version 16 + diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/META-INF/beans.xml b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/META-INF/beans.xml new file mode 100644 index 0000000..6f34698 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/META-INF/beans.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/META-INF/persistence.xml b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/META-INF/persistence.xml new file mode 100644 index 0000000..625444a --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/META-INF/persistence.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/controller/Controller.class b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/controller/Controller.class new file mode 100644 index 0000000..31e9d18 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/controller/Controller.class differ diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/model/DAO.class b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/model/DAO.class new file mode 100644 index 0000000..b0e8ee0 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/model/DAO.class differ diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/model/JavaBeans.class b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/model/JavaBeans.class new file mode 100644 index 0000000..f105d72 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/WEB-INF/classes/model/JavaBeans.class differ diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/itextpdf-5.5.13.2.jar b/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/itextpdf-5.5.13.2.jar new file mode 100644 index 0000000..dee1be8 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/itextpdf-5.5.13.2.jar differ diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/javax.mvc-api-1.0.0.jar b/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/javax.mvc-api-1.0.0.jar new file mode 100644 index 0000000..a5f2da3 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/javax.mvc-api-1.0.0.jar differ diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/mysql-connector-java-8.0.20.jar b/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/mysql-connector-java-8.0.20.jar new file mode 100644 index 0000000..f4bd739 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/WEB-INF/lib/mysql-connector-java-8.0.20.jar differ diff --git a/target/agenda-1.0-SNAPSHOT/WEB-INF/web.xml b/target/agenda-1.0-SNAPSHOT/WEB-INF/web.xml new file mode 100644 index 0000000..f6c358b --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + + agenda + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/agenda.jsp b/target/agenda-1.0-SNAPSHOT/agenda.jsp new file mode 100644 index 0000000..f81f633 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/agenda.jsp @@ -0,0 +1,62 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ page import="model.JavaBeans"%> +<%@ page import="java.util.ArrayList"%> + +<% +@ SuppressWarnings ("unchecked") +ArrayList lista = (ArrayList) request.getAttribute("contatos"); +%> + + + + + +Agenda de contatos + + + + +
+
+

Agenda de contatos

+
+ +
+ + + + + + + + + + + + <% + for (int i = 0; i < lista.size(); i++) { + %> + + + + + + + + <% + } + %> + +
IdNomeTelefoneEmailOpções
<%=lista.get(i).getIdcon()%><%=lista.get(i).getNome()%><%=lista.get(i).getFone()%><%=lista.get(i).getEmail()%>
+ + + \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/editar.jsp b/target/agenda-1.0-SNAPSHOT/editar.jsp new file mode 100644 index 0000000..72e12aa --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/editar.jsp @@ -0,0 +1,38 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ page import="model.JavaBeans"%> + + + + + +Agenda + + + + +
+

Editar contato

+
+
+ + + + + + + + + + + + + + + +
">
">
">
">
+ +
+ + + \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/imagens/agenda.png b/target/agenda-1.0-SNAPSHOT/imagens/agenda.png new file mode 100644 index 0000000..3d86cc8 Binary files /dev/null and b/target/agenda-1.0-SNAPSHOT/imagens/agenda.png differ diff --git a/target/agenda-1.0-SNAPSHOT/imagens/favicon.svg b/target/agenda-1.0-SNAPSHOT/imagens/favicon.svg new file mode 100644 index 0000000..4ff0308 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/imagens/favicon.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/agenda-1.0-SNAPSHOT/index.html b/target/agenda-1.0-SNAPSHOT/index.html new file mode 100644 index 0000000..cd40383 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/index.html @@ -0,0 +1,17 @@ + + + + +Agenda + + + + +
+ +

Agenda de Contatos

+ Acessar +
+ + \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/novo.html b/target/agenda-1.0-SNAPSHOT/novo.html new file mode 100644 index 0000000..304c596 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/novo.html @@ -0,0 +1,31 @@ + + + + +Agenda + + + + +
+

Criar novo contato

+
+
+ + + + + + + + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/scripts/confirmador.js b/target/agenda-1.0-SNAPSHOT/scripts/confirmador.js new file mode 100644 index 0000000..4e842de --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/scripts/confirmador.js @@ -0,0 +1,14 @@ +/** + * Validacao de Exclusao + * @author Andressa Silva + * @param idcon + */ + +function confirmar(idcon){ + let resposta = confirm("Confirma a exclusão deste contato?") + if(resposta === true){ + + //encaminhando o parametro idcon para controller + window.location.href = "delete?idcon=" + idcon + } +} \ No newline at end of file diff --git a/target/agenda-1.0-SNAPSHOT/scripts/validador.js b/target/agenda-1.0-SNAPSHOT/scripts/validador.js new file mode 100644 index 0000000..742df44 --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/scripts/validador.js @@ -0,0 +1,23 @@ +/** + * Validação de Formulário + * @author Andressa Silva + */ + +function validar() { + let nome = frmContato.nome.value + let fone = frmContato.fone.value + if (nome === "") { + alert('Preencha o campo Nome') + frmContato.nome.focus() + return false + + }else if(fone === "") { + alert('Preencha o campo Telefone') + frmContato.fone.focus() + return false + + }else { + document.forms["frmContato"].submit() + } +} + diff --git a/target/agenda-1.0-SNAPSHOT/style.css b/target/agenda-1.0-SNAPSHOT/style.css new file mode 100644 index 0000000..12ad27a --- /dev/null +++ b/target/agenda-1.0-SNAPSHOT/style.css @@ -0,0 +1,180 @@ +@charset "utf-8"; + +@import + url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap') + ; + +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + font-family: 'Roboto', sans-serif; + font-size: 1em; + font-weight: 400; +} + +.inicio { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} + +.agenda { + display: flex; + flex-direction: column; +} + +img { + margin-top: 20px; + margin-left: auto; + margin-right: auto; + width: 50%; +} + +.titulo { + margin-left: 20px; + margin-bottom: 20px; +} + +.borda-embaixo { + border-style: solid; + border-width: 0 0 5px 0; + border-color: #2E186A; +} + +h1 { + color: #2E186A; + margin-top: 20px; + font-size: 1.6em; +} + +.Botao1 { + font-size: 1em; + font-weight: 700; + color: #fff; + text-decoration: none; + background-color: #FE7624; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + border: 0; + cursor: pointer; +} + +.Botao4 { + font-size: 1em; + font-weight: 700; + color: #fff; + text-decoration: none; + background-color: #2E186A; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + border: 0; + cursor: pointer; + margin-left: 10px; +} + +nav { + padding: 10px; + justify-content: space-between; +} + +.navprincipal { + padding: 0; + margin-top: 30px; + margin-bottom: 16px; +} + +.BotaoAlterar { + font-weight: 500; + font-size: 1em; + color: #fff; + text-decoration: none; + background-color: #FE7624; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + border: 0; + cursor: pointer; +} + +.BotaoDeletar { + font-size: 1em; + font-weight: 500; + color: #fff; + text-decoration: none; + background-color: #e32636; + border-radius: 8px; + padding: 10px; + width: 120px; + text-align: center; + margin-top: 20px; + margin-left: 10px; + border: 0; + cursor: pointer; +} + +.agenda .Botao1 { + margin-left: 20px; + background-color: #228b22; +} + +form { + margin-top: 20px; + margin-left: 20px; +} + +.Caixa1 { + width: 320px; + padding: 5px; + margin-bottom: 10px; + border: 1px solid #2E186A; + border-radius: 5px; +} + +.Caixa2 { + padding: 5px; + margin-bottom: 10px; + border: 1px solid #2E186A; + border-radius: 5px; +} + +#Caixa3 { + padding: 5px; + margin-bottom: 10px; + border: 1px solid #FE7624; + border-radius: 5px; + display: none; +} + +#tabela { + margin-left: 20px; + margin-top: 20px; + border-collapse: collapse; + color: #2E186A; + font-size: 1.1em; +} + +#tabela th { + border: 1px solid #2E186A; + padding: 10px; + text-align: left; + background-color: #2E186A; + color: #fff; +} + +#tabela td { + border: 1px solid #2E186A; + padding: 10px; +} \ No newline at end of file diff --git a/target/classes/META-INF/beans.xml b/target/classes/META-INF/beans.xml new file mode 100644 index 0000000..6f34698 --- /dev/null +++ b/target/classes/META-INF/beans.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/target/classes/META-INF/persistence.xml b/target/classes/META-INF/persistence.xml new file mode 100644 index 0000000..625444a --- /dev/null +++ b/target/classes/META-INF/persistence.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/target/classes/controller/Controller.class b/target/classes/controller/Controller.class new file mode 100644 index 0000000..31e9d18 Binary files /dev/null and b/target/classes/controller/Controller.class differ diff --git a/target/classes/model/DAO.class b/target/classes/model/DAO.class new file mode 100644 index 0000000..b0e8ee0 Binary files /dev/null and b/target/classes/model/DAO.class differ diff --git a/target/classes/model/JavaBeans.class b/target/classes/model/JavaBeans.class new file mode 100644 index 0000000..f105d72 Binary files /dev/null and b/target/classes/model/JavaBeans.class differ