Date: 2004-09-16T11:05:45
Editor: NiallPemberton <[EMAIL PROTECTED]>
Wiki: Apache Struts Wiki
Page: StrutsCatalogSimpleDispatchAction
URL: http://wiki.apache.org/struts/StrutsCatalogSimpleDispatchAction
no comment
Change Log:
------------------------------------------------------------------------------
@@ -179,5 +179,47 @@
'''Michael !McGrady'''
+----
+Seems to me that most of the SimpleDispatchAction duplicates whats already in the
DispatchAction class. If we re-factored DispatchAction so that the parameter retrieval
was moved into a new getParameter() method then all that would be needed to achieve
what you want is a flavour that overrides the getParameter()/getMethodName() methods.
+
+Something along the lines of ...
+
+{{{
+public abstract class SimpleDispatchAction extends DispatchAction {
+
+ protected String getParameter(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+
+ return mapping.getParameter();
+
+ }
+
+ protected String getMethodName(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ String parameter) {
+
+ if((parameter != null) && (parameter.endsWith(".x"))) {
+ methodName = parameter.substring(0,parameter.indexOf('.'));
+ } else {
+ Enumeration enum = request.getParameterNames();
+ while(enum.hasMoreElements()) {
+ buttonValue = (String)enum.nextElement();
+ if(buttonValue.endsWith(".x")) {
+ methodName = buttonValue.substring(0,buttonValue.indexOf(".x"));
+ }
+ }
+ }
+ return methodName;
+ }
+
+}
+
+}}}
+
+'''Niall Pemberton'''
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]