org.apache.turbine.modules
Class ActionEvent

java.lang.Object
  extended by org.apache.turbine.modules.Assembler
      extended by org.apache.turbine.modules.Action
          extended by org.apache.turbine.modules.ActionEvent
Direct Known Subclasses:
VelocityActionEvent

public abstract class ActionEvent
extends Action

This is an alternative to the Action class that allows you to do event based actions. Essentially, you label all your submit buttons with the prefix of "eventSubmit_" and the suffix of "methodName". For example, "eventSubmit_doDelete". Then any class that subclasses this class will get its "doDelete(RunData data)" method executed. If for any reason, it was not able to execute the method, it will fall back to executing the doPeform() method which is required to be implemented.

Limitations:

Because ParameterParser makes all the key values lowercase, we have to do some work to format the string into a method name. For example, a button name eventSubmit_doDelete gets converted into eventsubmit_dodelete. Thus, we need to form some sort of naming convention so that dodelete can be turned into doDelete.

Thus, the convention is this:

If you follow these conventions, then you should be ok with your method naming in your Action class.

Version:
$Id: ActionEvent.java 1078552 2011-03-06 19:58:46Z tv $
Author:
Jon S. Stevens , Henning P. Schmiedehausen, Quinton McCombs, Peter Courcoux

Field Summary
protected  boolean bubbleUpException
          If true, then exceptions raised in eventSubmit_do methods as well as in doPerform methods are bubbled up to the Turbine servlet's handleException method.
protected static String BUTTON
          The name of the button to look for.
protected static int BUTTON_LENGTH
          The length of the button to look for.
protected static int LENGTH
          The length of the button to look for.
protected  org.apache.commons.logging.Log log
          Logging
protected static int METHOD_NAME_LENGTH
          The length of the method name.
protected static String METHOD_NAME_PREFIX
          The prefix of the method name.
 
Fields inherited from class org.apache.turbine.modules.Action
CACHE_SIZE_DEFAULT, CACHE_SIZE_KEY, NAME, PREFIX
 
Constructor Summary
ActionEvent()
          C'tor
 
Method Summary
protected  boolean considerKey(String key, org.apache.fulcrum.parser.ParameterParser pp)
          Checks whether the selected key really is a valid event.
 void doPerform(PipelineData pipelineData)
          You need to implement this in your classes that extend this class.
abstract  void doPerform(RunData data)
          Deprecated. use PipelineData version instead.
 void executeEvents(PipelineData pipelineData)
          This method should be called to execute the event based system.
 void executeEvents(RunData data)
          Deprecated. Use PipelineData version instead.
protected  String formatString(String input, org.apache.fulcrum.parser.ParameterParser pp)
          This method does the conversion of the lowercase method name into the proper case.
protected  void perform(PipelineData pipelineData)
          This overrides the default Action.perform() to execute the doEvent() method.
protected  void perform(RunData data)
          Deprecated. Use PipelineData version instead.
 
Methods inherited from class org.apache.turbine.modules.Action
getPrefix
 
Methods inherited from class org.apache.turbine.modules.Assembler
getRunData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log
Logging


BUTTON

protected static final String BUTTON
The name of the button to look for.

See Also:
Constant Field Values

BUTTON_LENGTH

protected static final int BUTTON_LENGTH
The length of the button to look for.


METHOD_NAME_PREFIX

protected static final String METHOD_NAME_PREFIX
The prefix of the method name.

See Also:
Constant Field Values

METHOD_NAME_LENGTH

protected static final int METHOD_NAME_LENGTH
The length of the method name.


LENGTH

protected static final int LENGTH
The length of the button to look for.


bubbleUpException

protected boolean bubbleUpException
If true, then exceptions raised in eventSubmit_do methods as well as in doPerform methods are bubbled up to the Turbine servlet's handleException method.

Constructor Detail

ActionEvent

public ActionEvent()
C'tor

Method Detail

doPerform

@Deprecated
public abstract void doPerform(RunData data)
                        throws Exception
Deprecated. use PipelineData version instead.

You need to implement this in your classes that extend this class.

Specified by:
doPerform in class Action
Parameters:
data - Turbine information.
Throws:
Exception - a generic exception.

doPerform

public void doPerform(PipelineData pipelineData)
               throws Exception
You need to implement this in your classes that extend this class. This should revert to being abstract when RunData has gone.

Overrides:
doPerform in class Action
Parameters:
data - Turbine information.
Throws:
Exception - a generic exception.

perform

@Deprecated
protected void perform(RunData data)
                throws Exception
Deprecated. Use PipelineData version instead.

This overrides the default Action.perform() to execute the doEvent() method. If that fails, then it will execute the doPerform() method instead.

Overrides:
perform in class Action
Parameters:
data - Turbine information.
Throws:
Exception - a generic exception.

perform

protected void perform(PipelineData pipelineData)
                throws Exception
This overrides the default Action.perform() to execute the doEvent() method. If that fails, then it will execute the doPerform() method instead.

Overrides:
perform in class Action
Parameters:
data - Turbine information.
Throws:
Exception - a generic exception.

executeEvents

@Deprecated
public void executeEvents(RunData data)
                   throws Exception
Deprecated. Use PipelineData version instead.

This method should be called to execute the event based system.

Parameters:
data - Turbine information.
Throws:
Exception - a generic exception.

executeEvents

public void executeEvents(PipelineData pipelineData)
                   throws Exception
This method should be called to execute the event based system.

Parameters:
data - Turbine information.
Throws:
Exception - a generic exception.

formatString

protected final String formatString(String input,
                                    org.apache.fulcrum.parser.ParameterParser pp)
This method does the conversion of the lowercase method name into the proper case.

Parameters:
input - The unconverted method name.
pp - The parameter parser (for correct folding)
Returns:
A string with the method name in the proper case.

considerKey

protected boolean considerKey(String key,
                              org.apache.fulcrum.parser.ParameterParser pp)
Checks whether the selected key really is a valid event.

Parameters:
key - The selected key
pp - The parameter parser to look for the key value
Returns:
true if this key is really an ActionEvent Key


Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.