Codice completo

Handler che eredita LookupDispatchAction

import javax.servlet.http.*;
import javax.servlet.*;
import org.apache.struts.actions.*;
import org.apache.struts.action.*;
import java.util.*;

public class UserLookupDispatchAction extends LookupDispatchAction {

  //  necessario implementare questo metodo che mappi
  // le chiavi del file di risorse ai nomi dei metodi
  protected Map getKeyMethodMap() {
  
    Map map = new HashMap();
    map.put("userForm.remove", "remove");
    map.put("userForm.save", "save");
    
    return map;
  }
  
  public ActionForward remove(ActionMapping mapping, ActionForm form,
                              HttpServletRequest request, HttpServletResponse response)
                              throws Exception {
    
    System.out.println("REMOVE USER!!!!");
    return mapping.findForward("success");
  }
  
  public ActionForward save(ActionMapping mapping, ActionForm form, 
                            HttpServletRequest request, HttpServletResponse response)
                            throws Exception {
    System.out.println("SAVE USER!!!!");
    return mapping.findForward("success");
  }
}