File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Can an action class  forward to another action class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can an action class  forward to another action class?" Watch "Can an action class  forward to another action class?" New topic
Author

Can an action class forward to another action class?

Polireddy Vanukuri
Greenhorn

Joined: Jul 24, 2006
Posts: 6
My stuts-config.xml is [having 3 action classes mapping information including a form-bean also]...

<struts-config>
<form-beans>
<form-bean type="btch.BatchBillForm" name="batchbillForm"/>
</form-beans>

<action-mappings>
<action type="btch.LoadControlFromDB" validate="false" scope="session" path="/Goto_BBE_Screen" name="batchbillForm">
<forward name="showBatchbill" path="/BatchBillEntry.jsp" />
</action>

<action type="btch.bbEntryAction" scope="session" path="/bbEntryAction" name="batchbillForm">
<forward name="showAddedBatchbill" path="/bbVAction" />
</action>

<action path="/bbVAction" type="btch.BBVAction" scope="session" name="batchbillForm">
<forward name="batchbill" path="/BatchBill.jsp"/>
</action>

</struts-config>


my home page is index.jsp which having an anchor link with hyper link- Goto_BBE_Screen.It is calling LoadControlFromDB action class which is in btch directory. That class after processing execute() forwarding to BatchBillEntry.jsp page with the following action mapping.

<action type="btch.LoadControlFromDB" validate="false" scope="session" path="/Goto_BBE_Screen" name="batchbillForm">
<forward name="showBatchbill" path="/BatchBillEntry.jsp" />
</action>

It is showing the BatchBillEntry.jsp page. It has a form with some fields. Form action path is -- bbEntryAction. It has the following mapping information in struts config file:

<action type="btch.bbEntryAction" scope="session" path="/bbEntryAction" name="batchbillForm">
<forward name="showAddedBatchbill" path="/bbVAction" />
</action>

After processing the 'bbEntryAction' action class, i have to forward the request to another action class 'BBVAction'. Following mapping information i am giving.

path="/bbEntryAction" name="batchbillForm">
<forward name="showAddedBatchbill" path="/bbVAction" />
</action>

Here is the problem i am getting. The error i am getting is..

Error: Requested resource with path=/bbVAction is not available.

All 3 action classes i am having in btch folder. It is calling 2 action classes as i mentioned above in config file. while calling 3rd action class it is giving above error.

What is the reason for this? Is there any need that i have to use global forwards? I tried that also. But same error(resource not available) i am getting.

Is it valid that an action class request forwarded to another action class?
If so,give me the solution for my problem.
Please help me regarding this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61006
    
  65

Moved to the Struts forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
You need to append the suffix to the action (like .do or whatever you use)
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Yea...I think the ".do" part is your problem. You may want to search around for information on "Action Chaining". I do not completely understand all the issue involved, but I know that there are issues with chaining multiple actions like you have proposed. If you can get away with adding redirect="true" to your forward, you will probably be better off (plus redirecting updates the URL that the user sees in the browser, eliminating some "user presses the refresh button" issues).

- Brent
Polireddy Vanukuri
Greenhorn

Joined: Jul 24, 2006
Posts: 6
Thanks for reply.
I tried by suffixing the path with .do in both request and response <action> paths. But I am getting same error again. My application won't show response in same page for every submit action.So here,there is no need of enabling redirect attribute.
I tried whole day with different possibilities(suffixing .do to path,defining a global forward with and without suffixing .do).

Please give me solution for my problem.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Where are you adding in ".do"? The only place that should show up is in the path attribute of your forward definition.

- Brent
 
Consider Paul's rocket mass heater.
 
subject: Can an action class forward to another action class?