There are numerous ways it could be done. It's really up to you on the
workflow you would like. One simple way is to just use the edit page as your
delete page as well.  We use one jsp page for add/edit/delete and have a
flag on our form bean indicating whether we are adding/editing/deleting. We
set the flag in the Action class, and check it in the jsp page. Based on its
state, the jsp page is rendered slightly differently. (Delete button instead
of Save button, read-only fields vs. input fields, etc.)

Here are a few code snippets:

** Action class snippet **      
public ActionForward deleteWidget(ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response) throws ServiceException {

  int widgetId = new Integer ((String) request.getParameter("widgetId
")).intValue();

  WidgetForm widgetForm = (WidgetForm) form;
  WidgetService widgetService = (WidgetService)
serviceManager.getService("Widget");
  widgetForm.setWidgetDTO((WidgetDTO) widgetService.getOneWidget
(widgetId));
  widgetForm.setMode(Constants.MODE_DELETE);
  return mapping.findForward(Constants.EDIT);
}

** JSP snippet **
<html:form action="/widget" onsubmit="return validateWidgetForm(this);">
  <tr>
    <td class="page_title">
      <c:choose>
        <c:when test="${widgetForm.mode == 'Insert'}">
          <fmt:message key="widgetTitle.add" bundle="${loc}"/>
        </c:when>
        <c:when test="${wdigetForm.mode == 'Update'}">
          <fmt:message key=" widgetTitle.edit" bundle="${loc}"/>
        </c:when>
        <c:when test="${ widget.mode == 'Delete'}">
          <fmt:message key=" widgetTitle.delete" bundle="${loc}"/>
        </c:when>
      </c:choose>
    </td>

Hope this helps.
Brian Barnett

-----Original Message-----
From: Julia Weaver [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 23, 2004 9:07 AM
To: Struts Users Mailing List
Subject: when delete a record 

Hi,

Can anyone please tell me:
How to do a confirmation when delete a record in
struts? 

Thank you,


                
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to