struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bOOyah <>
Subject Re: How to forward from one LookupDispatchAction to another LDA
Date Fri, 23 Apr 2004 16:34:50 GMT
Riyad Kalla wrote:

<snip />

> Does anyone know how I would be able to forward from one method in an 
> LDA to another method in the same LDA (or any other LDA for that 
> matter...)?

I do exactly this in my own apps.  I use Struts forward Actions in my 
struts-config.  What about something like this? (I'm assuming your 
exsiting Struts forwards and 'showList' method work):

     <!-- your main action -->
     <action path="/processMyProducts"
       <forward name="successShowList" path="/forward/product/showList"/>
       <!-- This might also work, but I don't use it nowadays and
            I cannot remember why:
           <forward name="successShowList"

     <!-- new, forward Action -->
     <action path="/forward/product/showList"

Your Action class:
public ActionForward execute(/* the usual args */) {
     ActionForward forward = new ActionForward("defaultErrHandler");

     String method= request.getParameter("method");

     if (method!= null && !method.equals("")) {
         if (method.equalsIgnoreCase("showList")) {
             forward = showList(mapping, form, request, response);
         else {
             forward = super.execute(mapping, form, request, response);
     return forward;
public ActionForward moveDown(/* the usual args */) {
     // Success! Now refresh the re-ordered list:
     return mapping.FindForward("successShowList");

public ActionForward showList(/* the usual args */) {
     // hit the DB for the new list and forward to the JSP
     // etc.

To summarise:
(1) The 'moveDown' handler is called.
(2) It looks up "successShowList" thereby forwarding to 
(4) "/forward/product/showList" forwards back into your Struts Action 
class with a 'method' parameter called 'showList' causing your existing 
'showList' method to execute.

That's all off the top of my head Riyad.  But I use that approach all 
the time.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message