Skip to content
Snippets Groups Projects
Commit 381ff49e authored by Fnac's avatar Fnac
Browse files

Invertir ordenes y cambiar mensjae enviado directamente a leido

parent 71ed0f0a
No related branches found
No related tags found
No related merge requests found
......@@ -150,4 +150,24 @@ public class mensajeDB {
return null;
}
}
public static int mnsajeLeido(int idMensaje) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
String consulta="UPDATE Mensaje SET leido = 1 WHERE idMensaje = ?";
try {
PreparedStatement ps =connection.prepareStatement(consulta);
ps.setInt(1, idMensaje);
int res = ps.executeUpdate();
ps.close();
pool.freeConnection(connection);
return res;
} catch (SQLException e) {
e.printStackTrace();
return 0;
}
}
}
......@@ -49,7 +49,7 @@ public class crearMensajeSV extends HttpServlet {
mensajeEnv.setAsunto(asunto);
mensajeEnv.setTexto(texto);
mensajeEnv.setFecha(fecha);
mensajeEnv.setLeido(0);
mensajeEnv.setLeido(1);
mensajeEnv.setTipo("Enviado");
HttpSession sesion = request.getSession();
......
......@@ -40,6 +40,12 @@ public class mensajeSV extends HttpServlet {
Mensaje mensaje = mensajeDB.getMensaje(idMensaje);
if(mensaje.getLeido() == 0){
mensajeDB.mnsajeLeido(idMensaje);
}
mensaje = mensajeDB.getMensaje(idMensaje);
request.setAttribute("mensaje", mensaje);
String url = "/mensajeEnviado.jsp";
......
......@@ -49,7 +49,7 @@ and open the template in the editor.
alt="Imagen del perfil de usuario"></li>
<li><h1><%=autor%></h1></li>
<li>
<button type="submit" class="enviar_mensaje" onclick="window.location.href='crearMensaje.jsp'">Enviar mensaje</button>
<button type="submit" class="enviar_mensaje" onclick="window.location.href='crearMensaje.jsp?emisor=<%=autor%>'">Enviar mensaje</button>
</li>
</ul>
</div>
......
......@@ -58,7 +58,7 @@ and open the template in the editor.
ArrayList<Nook> misNooks = (ArrayList<Nook>) request.getAttribute("misNooks");
ArrayList<String> misNooksCategorias = (ArrayList<String>) request.getAttribute("misNooksCategorias");
ArrayList<Integer> valoraciones = (ArrayList<Integer>) request.getAttribute("valoraciones");
for(int i = 0; i < misNooks.size(); i++){
for(int i = misNooks.size() - 1; i > 0; i--){
%>
<div class="nook_n">
<div class="nook_n_img">
......
......@@ -113,7 +113,7 @@ and open the template in the editor.
<%
ArrayList<Comentario> comentarios = (ArrayList<Comentario>) request.getAttribute("comentarios");
ArrayList<Integer> cValoraciones = (ArrayList<Integer>) request.getAttribute("cValoraciones");
for(int i = 0; i < comentarios.size(); i++){
for(int i = comentarios.size() - 1; i > 0; i--){
%>
<li>
<div class="comentarioTexto" method="post" action="/valorarComentarioSV?">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment