Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/07/2007, 03:02
solyluna
 
Fecha de Ingreso: enero-2007
Mensajes: 156
Antigüedad: 18 años, 3 meses
Puntos: 1
Exclamación No recarga la pagina

Hola amigos, tengo un pequeño problema con mi página web. Resulta que cuando realizo una acción, y debe volver a consultar de la base de datos, no actualiza correctamente la página y no se a qué se debe. Les pongo algo de código:

Código:
public ActionForward execute(ActionMapping actionMapping,
			ActionForm actionForm, 
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse)
	throws Exception {
		try {			
			Empleado actual=(Empleado)httpServletRequest.getSession(true).getAttribute("empAct");
			
			// solo puede acceder el administrador
			if (!actual.getPerfil().equals("ADMINISTRADOR")){
				return new ActionForward(actionMapping.findForward("sinPrivilegio"));
			}
			
			List<Mensaje> mensajes=MensajeDAO.mensajesLeidos();
			List<Noticia> noticias=NoticiaDAO.noticiasCaducadas();
			 
			httpServletRequest.setAttribute("mensajes", mensajes);
			httpServletRequest.setAttribute("noticias", noticias);
			
			System.out.println("mantenimiento");
			return new ActionForward(actionMapping.findForward("operacionesMantenimiento"));
			
				
		} catch (Exception e) {
			System.out.println("error en MantenimientoAction");
			return new ActionForward(actionMapping.findForward("error"));
		}
En este primer método recojo los mensajes y noticias para mostrarlos desde la siguiente pagina jsp.

Código:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title><bean:message key="empresa.titulo"/></title>
</head>
<body>

	<p><b>¡CUIDADO!</b>La información aqui eliminada desaparecerá de la
	base de datos de forma permanente.</p>
	
	<br/><br/>
	<div id="tabla">
		<table border="0" width="600" cellpadding="5">
			<tr>
				<th>MENSAJES</th>
			</tr>
			<tr>
				<td>
					<table border="0"  width="80%" align="center">
						<tr>
							<td><b>remite</b></td>
							<td><b>destino</b></td>
							<td colspan="2"><b>fecha</b></td>
						</tr>
						<logic:iterate id="mensaje" name="mensajes">
							<tr>
								<td width="100"><bean:write name="mensaje" property="remite"/></td>
								<td width="100"><bean:write name="mensaje" property="empleado.nombre"/></td>
								<td><bean:write name="mensaje" property="fecha"/></td>
								<td align="right">
									<html:link action="/EliminaMensajeAction" paramName="mensaje"
										paramProperty="idMensaje" paramId="idMensaje">eliminar</html:link>
								</td>
							</tr>
						</logic:iterate>
					</table>
				</td>
			</tr>
			<tr>
				<th>NOTICIAS</th>
			</tr>
			<tr>
				<td>
					<table border="0"  width="80%" align="center">
						<tr>
							<td><b>título</b></td>
							<td colspan="3"><b>fecha</b></td>
						</tr>
						<logic:iterate id="noticia" name="noticias">
							<tr>
								<td width="100"><bean:write name="noticia" property="titulo"/></td>
								<td><bean:write name="noticia" property="fecha"/></td>
								<td align="right" colspan="2">
									<html:link action="/EliminaNoticiaAction">eliminar</html:link>
								</td>
							</tr>
						</logic:iterate>
					</table>
				</td>
			</tr>
			
		</table>
	</div>
	
</body>
</html:html>
y el action que elimina el mensaje:

Código:
public ActionForward execute(ActionMapping actionMapping,
			ActionForm actionForm, 
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse)
	throws Exception {
		
		try {
			Empleado actual=(Empleado)httpServletRequest.getSession(true).getAttribute("empAct");
			
			// solo puede acceder el administrador
			if (!actual.getPerfil().equals("ADMINISTRADOR")){
				return new ActionForward(actionMapping.findForward("sinPrivilegio"));
			}
			
			System.out.println("se procede a eliminar");
			
			int idMensaje=Integer.parseInt(httpServletRequest.getParameter("idMensaje"));
			System.out.println(idMensaje);
			MensajeDAO.delete(MensajeDAO.find(idMensaje));
			
			return new ActionRedirect(actionMapping.findForward("calculaMantenimiento"));
			
			
		} catch (Exception e) {
			System.out.println("sale con excepcion EliminaMensajeAction");
			return new ActionForward(actionMapping.findForward("error").getPath());
		}
los trozos del struts-config.xml implicados:

Código:
<forward 
        	name="operacionesMantenimiento" 
        	path="/Mantenimiento.do" />
        	
        <forward 
        	name="calculaMantenimiento" 
        	path="/MantenimientoAction.do" />

<action 
     		path="/MantenimientoAction"
     		type="inmobiliaria.action.administrador.MantenimientoAction" />
     	
		<action 
			path="/Mantenimiento"
			forward="/pages/administrador/mantenimiento.jsp" />    
			
		<action 
			path="/EliminaMensajeAction"
			type="inmobiliaria.action.administrador.EliminaMensajeAction" />
La eliminación del mensaje lo hace correctamente pero cuando debiera volver a calcular la lista de mensajes restantes no hace la actualización.

Me urge mucho este tema pues llevo ya varios meses y no consigo encontrarle solución.

MUchas gracias por su atención y espero que alguien pueda ayudarme.

Saludos