Struts: Rufen Sie eine Methode von Dispatch Action von einer anderen DispatchAction aufJava

Java-Forum
Anonymous
 Struts: Rufen Sie eine Methode von Dispatch Action von einer anderen DispatchAction auf

Post by Anonymous »

Ich möchte eine Methode von „dispatchAction“ aus einer anderen Dispatch-Aktion aufrufen.
Ich möchte, dass, wenn ich auf „Aktualisieren“ oder „Löschen“ klicke, „Inside display user method“ auf meinem JSP angezeigt wird.

Struts-Konfigurationsdatei

Code: Select all











Versandaktionsklassen

Code: Select all

public class UserAction extends DispatchAction {

/* forward name="success" path="" */
private final static String SUCCESS = "success";

/**
* This is the Struts action method called on
* http://.../actionPath?method=myAction1,
* where "method" is the value specified in  element :
* (  )
*/
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;

return mapping.findForward("dispatch");
}

public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
userForm.setMessage("Inside update user method.");
return mapping.findForward(SUCCESS);
}

public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
userForm.setMessage("Inside delete user method.");
return mapping.findForward(SUCCESS);
}
}

Code: Select all

public class TestDispatchAction extends DispatchAction {

/* forward name="success" path="" */
private final static String SUCCESS = "success";

/**
* This is the Struts action method called on
* http://.../actionPath?method=myAction1,
* where "method" is the value specified in  element :
* (  )
*/
public ActionForward display(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
userForm.setMessage("Inside display user method.");
return mapping.findForward(SUCCESS);
}

}
JSP-Seite

Code: Select all



function submitForm() {
document.forms[0].action = "UserAction.do?methodtocall=add";
document.forms[0].submit();
}








delete




Danke

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post