Hi!
I'm writing because of a problem I have, and I think it has to do with a
problem in Struts. I use Struts 1.3.8, Ubuntu, Netbeans 6.0 and JDK 6. The
problem started as a NullPointerException, but after hours and hours trying
everything I realized that my execute method is executed twice. Why do I get
a NullPointer? Because what the action does is to delete an user in the DB,
and before that I print the name of the user, and, of course, the second
time I get a null when I go to the DB to get that user.
I've checked in the rest of my Actions, and this one is the only one that is
executed twice .
Please, if someone can help I'd be so grateful. In the following paragraphs
you can see the parts of code that are involved on this.
struts-config.xml
=============
<action path="/DeleteUserAdminAction" type="actions.DeleteUserAdminAction"
validate="false">
<forward name="Success"
path="/WEB-INF/jsps/user/deletedUser.jsp"/>
</action>
JSP with the link DeleteUserAdminAction.do
================================
<logic:iterate id="user" name="users" scope="request">
<tr>
<td>${user.login}</td>
<td>${user.nombre}</td>
<td>${user.apellidos}</td>
<td>${user.role}</td>
<td>
<html:link href="#" title="Ver en Detalle este Usuairo"
onclick="window.open('UserDetailAction.do?id_usuario=${user.id_usuario}&pop=yes',
'Ven en detalle Datos del Usuario',
'height=850,width=900,scrollbars=1,status=1,resizable=0')"><html:image
src="${pageContext.request.contextPath}/im/ic_eye.gif" /></html:link>
<logic:equal value="Administrador" name="usuario"
property="role" scope="session">
<javi:encryptUrl
urlBeforeQuestionMark="GoToUpdateUserFormAdminAction.do"
urlAfterQuestionMark="id_usuario=${user.id_usuario}" pageVar="urlUpdate"/>
<html:link href="${urlUpdate}" title="Actualizar los
datos asociados a este Usuario"><html:image
src="${pageContext.request.contextPath}/im/ic_open_win.gif" /></html:link>
<javi:encryptUrl
urlBeforeQuestionMark="DeleteUserAdminAction.do"
urlAfterQuestionMark="id_usuario=${user.id_usuario}" pageVar="urlDelete"/>
<html:link href="${urlDelete}" title="Eliminar a este
Usuario de la Aplicación"><html:image
src="${pageContext.request.contextPath}/im/ic_remove.gif" /></html:link>
</logic:equal>
</td>
</tr>
</logic:iterate>
The execute of the Action
===================
ActionForward forward = null;
long id_usuario =
Long.parseLong(Utils.decryptParameter("id_usuario", request));
UsuarioDao usuarioDao = new UsuarioDao();
Usuario usuario = usuarioDao.selectUserById(id_usuario);
usuarioDao.deleteUser(id_usuario);
log.info("El Usuario " + usuario.getNombre() + " " +
usuario.getApellidos() + " ha sido eliminado de la Aplicación. Acción
realizada por el usuario: " +
"" +
((Usuario)request.getSession().getAttribute("usuario")).getNombre() + " " +
((Usuario)request.getSession().getAttribute("usuario")).getApellidos());
forward = mapping.findForward("Success");
return forward;
The JSP after the Action executes the execute method
=========================================
El Usuario ha sido eliminado correctamente de la Base de Datos.
<br/>
<html:link href="ListAllUsersAction.do" title="Pulsar para volver a listar
todos los usuarios"><html:button property="" value="Vovler a Listar Todos
los Usuarios"/></html:link>
Seriously, this problem is driving me crazy. I've tried everything, and I
don't see where the problem is.
Thanks a lot in advance.
Regards.
--
View this message in context:
http://www.nabble.com/The-execute-method-of-my-Action-is-executed-twice-tp18930418p18930418.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]