booya I really appreciate the code snippets and explination! I hadn't gotten
involved in ActionForwards and appreciate you shedding light on the situation
for me.
Best,
Riyad
On Friday 23 April 2004 09:34 am, bOOyah wrote:
> 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):
>
> Struts-Config.xml:
> =================
> <!-- 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"
> path="/processMyProducts.do?method=showList"/>
> -->
> </action>
>
> <!-- new, forward Action -->
> <action path="/forward/product/showList"
> parameter="/processMyProducts.do?method=showList"
> type="org.apache.struts.actions.ForwardAction"/>
>
>
> 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
> "/forward/product/showList".
> (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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]