If I understood your question right you want to forward to another from
within an action. You can do this like this (after reading the code pastings
read the explanation right at the bottom)-
-----------------struts-config.xml-----
<action path="/singleSearch"
type="com.boeing.etrac.action.SingleSearchAction"
scope="request"
validate="false">
<forward name="retrieveLookAheadAction"
path="/retrieveLookAheadRecord.do"/>
<forward name="errorPage" path="/jsp/etracError.jsp"/>
</action>
<action path="/retrieveLookAheadRecord"
type="com.boeing.etrac.action.RetrieveLookAheadRecordAction"
scope="request"
validate="false">
<forward name="success" path="/jsp/shortageRecordDetail.jsp"/>
<forward name="errorPage" path="/jsp/etracError.jsp"/>
</action>
----------------------------------------------
---------------SingleSearchAction.java-----------------
public org.apache.struts.action.ActionForward
performAction(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws
javax.servlet.ServletException, java.io.IOException
{
//create a dummy light shortagerecord and put it in the record
container
//contains at lease one element. This is for the RecordInfoTag to
work
//properly.
LightShortageRec rec = new LightShortageRec();
Vector list = new Vector();
list.addElement(rec);
RecordsContainer container = new RecordsContainer(list);
UserSessionInfo sessionInfo =
EtracSessionManager.getUserSessionInfo(request.getSession());
sessionInfo.setRecordsContainer(container);
//forward to the appropriate action to continue processing.
return mapping.findForward("retrieveLookAheadAction");
}
---------
What I am doing is, in the SingleSearchAction I am doing some preocessing
and then forwarding to the RetrieveLookaAheadRecordAction which is declared
as a forward in the declaration of the SingleSearchAction(see the
struts-config.xml).
thanks
Srinivas
-----Original Message-----
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 05, 2002 1:40 AM
To: [EMAIL PROTECTED]
Subject: Calls another action from one action?
Subject: Calls another action from one action?
From: "Hu Ji Rong" <[EMAIL PROTECTED]>
===
Hi,
As I described in my previous post: "Question on implementation with
frames", I have some links pointing to some pages in which all form fields
actually belong to the same domain object, eg. Airport has pages like
AirportDef, Notes, Remarks,...
So I will implement the links with one single action, AirportAction, with
parameters, the AirportAction forward to different pages based on the link
clicked. Normally, we have the submit button inside each page(form) to
submit the form. But I can't have that, the requirement is when the user
click other links, current form will be submited.(eg. when user has
completed the AirportDef page and click the next link to Notes, the form in
AirportDef must be submitted.)
So, when a link is clicked, there are two things the action need to do,
submit the current form and forward to next page. Since the forwarding is
done in AirportAction, while CRUD of AirportDef is done in AirportDefAction,
I have to call the function in AirportDefAction inside AirportAction before
forward to next page.
So the question is can I invoke another action inside one action? Or how to
achieve it?
JiRong
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>