This patch fixes a bug on my machine !
The action event method is looked up using RunData.class, but if invoked
with PipelineData.class.
NOTE: this patch is different from the one in my previous post !
--
Leandro Rodrigo Saad Cruz
InterBusiness Tecnologia e Servi�os
IB - www.ibnetwork.com.br
DB - www.digitalbrand.com.br
OJB - db.apache.org/ojb
XINGU - xingu.sf.net
Index: src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java,v
retrieving revision 1.22
diff -u -b -B -r1.22 VelocityActionEvent.java
--- src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java 2 Aug 2004 08:57:36 -0000 1.22
+++ src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java 15 Oct 2004 21:01:06 -0000
@@ -187,54 +187,17 @@
public void executeEvents(RunData data, Context context)
throws Exception
{
- // Name of the button.
- String theButton = null;
-
- // ParameterParser.
- ParameterParser pp = data.getParameters();
-
- String button = pp.convert(BUTTON);
- String key = null;
-
- // Loop through and find the button.
- for (Iterator it = pp.keySet().iterator(); it.hasNext();)
- {
- key = (String) it.next();
- if (key.startsWith(button))
- {
- if (considerKey(key, pp))
- {
- theButton = formatString(key);
- break;
- }
- }
- }
-
- if (theButton == null)
- {
- throw new NoSuchMethodException(
- "ActionEvent: The button was null");
- }
-
- Method method = null;
+ String methodName = findMethodName(data);
try
{
- method = getClass().getMethod(theButton, methodParams);
- Object[] methodArgs = new Object[] { data, context };
-
- if (log.isDebugEnabled())
- {
- log.debug("Invoking " + method);
- }
-
- method.invoke(this, methodArgs);
+ executeEvent(methodName,new Object[]{data, context});
}
catch (NoSuchMethodException nsme)
{
// Attempt to execute things the old way..
if (log.isDebugEnabled())
{
- log.debug("Couldn't locate the Event ( " + theButton
+ log.debug("Couldn't locate the Event ( " + methodName
+ "), running executeEvents() in "
+ super.getClass().getName());
}
@@ -244,13 +207,9 @@
catch (InvocationTargetException ite)
{
Throwable t = ite.getTargetException();
- log.error("Invokation of " + method , t);
+ log.error("Invokation of " + methodName , t);
throw ite;
}
- finally
- {
- pp.remove(key);
- }
}
/**
@@ -264,6 +223,51 @@
throws Exception
{
RunData data = (RunData) getRunData(pipelineData);
+ String methodName = findMethodName(data);
+ try
+ {
+ executeEvent(methodName,new Object[]{pipelineData, context});
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // Attempt to execute things the old way..
+ if (log.isDebugEnabled())
+ {
+ log.debug("Couldn't locate the Event ( " + methodName
+ + "), running executeEvents() in "
+ + super.getClass().getName());
+ }
+
+ super.executeEvents(pipelineData);
+ }
+ catch (InvocationTargetException ite)
+ {
+ Throwable t = ite.getTargetException();
+ log.error("Invokation of " + methodName , t);
+ throw ite;
+ }
+ }
+
+ protected void executeEvent(String methodName, Object[] params)
+ throws Exception
+ {
+ Method method = getClass().getMethod(methodName, methodParams);
+ Object obj = params[0];
+ if(obj instanceof PipelineData)
+ {
+ params[0] = getRunData((PipelineData) obj);
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Invoking " + method);
+ }
+ method.invoke(this, params);
+ }
+
+ protected String findMethodName(RunData data)
+ throws NoSuchMethodException
+ {
// Name of the button.
String theButton = null;
@@ -292,42 +296,8 @@
throw new NoSuchMethodException(
"ActionEvent: The button was null");
}
-
- Method method = null;
- try
- {
- method = getClass().getMethod(theButton, methodParams);
- Object[] methodArgs = new Object[] { pipelineData, context };
-
- if (log.isDebugEnabled())
- {
- log.debug("Invoking " + method);
- }
-
- method.invoke(this, methodArgs);
- }
- catch (NoSuchMethodException nsme)
- {
- // Attempt to execute things the old way..
- if (log.isDebugEnabled())
- {
- log.debug("Couldn't locate the Event ( " + theButton
- + "), running executeEvents() in "
- + super.getClass().getName());
- }
-
- super.executeEvents(pipelineData);
- }
- catch (InvocationTargetException ite)
- {
- Throwable t = ite.getTargetException();
- log.error("Invokation of " + method , t);
- throw ite;
- }
- finally
- {
pp.remove(key);
- }
+ return theButton;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]