Hi Michael,
First thanks for the response
I had thought that would work as well, but the unspecified method executes
only when the parameter is not present.
http://localhost:8080/myapp/UserOrders.do
So this would execute, unspecified(Action blahblahblah), however
DispatchAction throws a NoSuchMethodException when the parameter specifies a
method that does not exist.
http://localhost:8080/myapp/UserOrders.do?export=amethodnamethatdoesnotexist
So that's the issue, I'm having. It seems that the unspecified method is
not a catch-all, method.
Edward Song
-Original Message-
From: Griffith, Michael * [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2008 4:15 PM
To: Struts Users Mailing List
Subject: RE: DispatchAction nonexisting method
Hi Edward,
Create a method for handling all the rest or unspecified actions, and
delegate to your view:
protected ActionForward unspecified(ActionMapping mapping, ActionForm
form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return getView(mapping, form, request,
response);
}
MG
From: Edward Song [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2008 3:04 PM
To: 'Struts Users Mailing List'
Subject: DispatchAction nonexisting method
Hi all,
First, this is not a Struts 2 question
And thanks to anyone who reads below...
I was wondering how other's handled this problem with the
org.apache.struts.actions.DispatchAction in Struts 1.3.9.
I have an action that calls a data service that is to be presented to
the user in numerous formats by using DispatchAction.
* View
* XLS
* PDF
As they all utilizes a common data service, I thought that this would be
an excellent candidate for DispatchAction to centralize the call into
one action.
Say the parameter used was named export, so my action mapping looks
like,
action path=/UserOrders
type=com.nuhorizons.web.shop.actions.UserOrders scope=request
parameter=export
forward name=success
path=/WEB-INF/jsps/pages/userOrders.jsp/
/action
UserOrders extends DispatchAction and all this is working fine.
I implement the following methods.
public ActionForward unspecified(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
public ActionForward excel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
public ActionForward pdf(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
All is well, until...
http://localhost:8080/myapp/UserOrders.do?export=unnamedmethod
When DispatchAction attempts to find the unnamedmethod, it throws a
NoSuchMethodException prior to calling any method. Our app is
configured to show a 500 page, and I know that I could use the
global-exceptions and create an exception handler but the
NoSuchMethodException is such a generic exception. Wrapping the
exception is not really an option as it is thrown by DispatchAction.
Has anyone thought of a good way for DispatchAction to handle an unnamed
method??
Ed
The information contained in this e-mail is legally privileged and confidential
information intended only for use by the individual or entity named above. If
the reader of this e-mail is not the intended recipient, you are hereby
notified that any dissemination or distribution hereof is prohibited. If you
have received this e-mail in error, please delete the material from your
computer and immediately notify us at 631-396-5000. Thank you.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]