Hi!
I need some help with deleting some records from the database. I have two tables EVENT with
column: eventId and EVENTTIMETABLE with columns: eventTimeTableId and eventId. I want to delete
an event with a certain Id and all the timetables corresponding to that event. I will send
my code... if you please look at it and tell me what I do wrong because my deleteEventAction
doesen't work!
public void deleteEvent(int eventId) throws DaoException {
try {
eventDaoManager.startTransaction();
eventDao.deleteEvent(eventId);
eventDaoManager.commitTransaction();
} catch (DaoException e) {
try { storeDaoManager.rollbackTransaction(); } catch (Exception e2)
throw ((DaoException) e.fillInStackTrace());
}
}
void deleteEvent(int eventId)
throws DaoException;
public void deleteEvent(int eventId)
throws DaoException {
Object parameterObject = new Integer(eventId);
executeUpdate("deleteEvent", parameterObject);
}
<mapped-statement name="deleteEvent">
delete EVENT,EVENTTIMETABLE fromEVENT,EVENTTIMETABLE where EVENT.EVENTID = #value# and
EVENT.EVENTID = EVENTTIMETABLE.EVENTID
</mapped-statement>
public class DeleteEventAction extends BaseAction {
public ActionForward doPerform(ActionMapping mapping, ActionForm form, HttpServletRequest
request, HttpServletResponse response) throws Exception {
OrganizAccountForm orgAcctForm = (OrganizAccountForm) form;
String orgUsername = orgAcctForm.getOrganizAccount().getOrgUsername();
int eventId = Integer.parseInt(request.getParameter("eventId"));
tugis.deleteEvent(eventId);
request.setAttribute("eventList", tugis.getEventsByOrgUsername(orgUsername));
return mapping.findForward("success");
}
}
<action path="/portal/deleteEvent" type="tugis.presentation.action.DeleteEventAction"
name="organizAccountForm" scope="session"
validate="true" input="/jsp/ViewRegisteredEvent.jsp">
<forward name="success" path="/jsp/ListEvents.jsp"/>
</action>
And in the JSP code:
<html:link paramId="eventId" paramName="event" paramProperty="eventId" page="/portal/deleteEvent.do">Delete</html:link>
Well, please someone take a look and help me out! Or maybe someone have done something similar
already and send me an example!
Thanks!
Laura
---------------------------------
Discover Yahoo!
Have fun online with music videos, cool games, IM & more. Check it out!
|