com.cc.framework.adapter.struts
Interface FrameworkAction

All Known Implementing Classes:
FWAction, FWDispatchAction, FWLookupDispatchAction

public interface FrameworkAction

Interface for all common-controls actions

Version:
$Revision: 1.2 $
Author:
Harald Schulz

Method Summary
 void applyControlStates(ActionContext ctx)
          Applies the serialized control state from the HTTPRequest to the corresponding control instances.
 void cleanup(ActionContext ctx)
          This method do some cleanup after the action finished.
 ActionContext createActionContext(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This method is called to create the ActionContext wrapper.
 void doExecute(ActionContext ctx)
          A template method which must be overridden by the subclass.
 void doPostExecute(ActionContext ctx)
          A template method.
 boolean doPreExecute(ActionContext ctx)
          A template method.
 void doRenderAjaxResponse(ActionContext ctx, javax.servlet.jsp.PageContext pageContext)
          Renders the AJAX XML response
 void doSetMenuContext(ActionContext ctx, MenuContext menuCtx)
          Sets the menu context.
 void execute(ActionContext ctx)
          This method is called instead the struts execute.
 java.lang.reflect.Method getActionHandler(ControlActionContext ctx, java.lang.Object[] params)
          Searches the action class for a handler method.
 Control getControlByName(ActionContext ctx, java.lang.String name)
          The framework has a default pattern where to search a control instance.
 DialogContext getDialogContext(ActionContext ctx, boolean create)
          Returns or creates a dialog context
 ActionContext handleControlAction(ActionContext ctx, ControlMethodInvocation cmi)
          Handles an action which comes from a control on the form an delegates the request to the control.
 void handleControlAction(ControlActionContext ctx, java.lang.Object[] params)
          Handles an action which comes from a control on the form.
 ActionContext handleFormAction(ActionContext ctx)
          Checks if the request comes from a form button (save, cancel, ...) and delegates the request to the corresponding handler for the button which must be implemented in the (action) subclass.
 void setControlValue(ActionContext ctx, ControlValuePath path, java.lang.String[] values)
          This method is called to set a control element value
 void setControlValuesFromRequest(ActionContext ctx)
          This method is called to updates any control element data from request values.
 

Method Detail

cleanup

public void cleanup(ActionContext ctx)
This method do some cleanup after the action finished. The default implementation removes the form bean.

Parameters:
ctx - ActionContext

getDialogContext

public DialogContext getDialogContext(ActionContext ctx,
                                      boolean create)
Returns or creates a dialog context

Parameters:
ctx - The ActionContext
create - Indicates if an existing context should be returned (false); otherwise a new context is started (true)
Returns:
DialogContext

createActionContext

public ActionContext createActionContext(org.apache.struts.action.ActionMapping mapping,
                                         org.apache.struts.action.ActionForm form,
                                         javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response)
This method is called to create the ActionContext wrapper. Overwrite this method to use your own implementation

Parameters:
mapping - Struts Action Mapping
form - Struts Action Form
request - HTTPServletRequest
response - HTTPServletResponse
Returns:
ActionContext which is passed to the doExecute() method

getControlByName

public Control getControlByName(ActionContext ctx,
                                java.lang.String name)
                         throws java.lang.Exception
The framework has a default pattern where to search a control instance. If the control can not be found by the implemented pattern, this method can be overwritten to implement an additional or own processing. First the control will be searched in the session, then the control will be searched in the FormBean which is associated with the action.

Parameters:
ctx - The ActionContext
name - The name of the bean
Returns:
Control
Throws:
java.lang.Exception - If an exception occurred

applyControlStates

public void applyControlStates(ActionContext ctx)
                        throws java.lang.Exception
Applies the serialized control state from the HTTPRequest to the corresponding control instances.

Parameters:
ctx - ActionContext
Throws:
java.lang.Exception - if an exception occurs

getActionHandler

public java.lang.reflect.Method getActionHandler(ControlActionContext ctx,
                                                 java.lang.Object[] params)
Searches the action class for a handler method. The search order is

Parameters:
ctx - the action context
params - actual parameters
Returns:
returns a handler method or null when no such method is defined

handleControlAction

public ActionContext handleControlAction(ActionContext ctx,
                                         ControlMethodInvocation cmi)
                                  throws java.lang.Exception
Handles an action which comes from a control on the form an delegates the request to the control.

Parameters:
ctx - ActionContext
cmi - ControlMethodInvocation
Returns:
ActionContext
Throws:
java.lang.Exception - if an exception occurs

handleControlAction

public void handleControlAction(ControlActionContext ctx,
                                java.lang.Object[] params)
                         throws java.lang.Exception
Handles an action which comes from a control on the form. If the subclass does not implement a special processing for this event, the event will be forwarded to the control. So the control can do some default processing. This default behavior can be changed if an event handler in the subclass is implemented. This handler must follow the naming convention "controlname_onEventname(ControlRequestContext ctx, parameters ...) For example: users_onDrilldown(ControlRequestContext ctx, String key) Note: An other way to change the default behavior of an existing control is to subclass the control an write an new control.

Parameters:
ctx - ControlRequestContext
params - Parameters
Throws:
java.lang.Exception - if an exception occurs

setControlValue

public void setControlValue(ActionContext ctx,
                            ControlValuePath path,
                            java.lang.String[] values)
                     throws java.lang.Exception
This method is called to set a control element value

Parameters:
ctx - The ActionContext
path - The Pathname of the value
values - The value itself
Throws:
java.lang.Exception - is thrown when a value could not be set

setControlValuesFromRequest

public void setControlValuesFromRequest(ActionContext ctx)
                                 throws java.lang.Exception
This method is called to updates any control element data from request values. All nested control element values follow the naming convention documented in ControlValuePath

Parameters:
ctx - The ActionContext
Throws:
java.lang.Exception - is thrown when a value could not be set

handleFormAction

public ActionContext handleFormAction(ActionContext ctx)
                               throws java.lang.Exception
Checks if the request comes from a form button (save, cancel, ...) and delegates the request to the corresponding handler for the button which must be implemented in the (action) subclass. This handler must follow the naming convention "buttonname_onEventname(FormActionContext ctx) For example save_onClick(FormActionContext ctx)

Parameters:
ctx - The ActionContext
Returns:
ActionContext
Throws:
java.lang.Exception - If an exception occurred

execute

public void execute(ActionContext ctx)
             throws java.lang.Exception
This method is called instead the struts execute.

Parameters:
ctx - ActionContext
Throws:
java.lang.Exception - if an exception occurs

doPreExecute

public boolean doPreExecute(ActionContext ctx)
                     throws java.lang.Exception
A template method. Can be overridden by a subclass and is executed before the doExecute method is called. The method must return true if the doExecute method should be called.

Parameters:
ctx - The ActionContext
Returns:
true if the doExecute() should be processed; false otherwise
Throws:
java.lang.Exception - If an exception occurred

doPostExecute

public void doPostExecute(ActionContext ctx)
                   throws java.lang.Exception
A template method. Can be overridden by a subclass and is executed after the doExecute method was called.

Parameters:
ctx - The ActionContext
Throws:
java.lang.Exception - If an exception occurred

doExecute

public void doExecute(ActionContext ctx)
               throws java.lang.Exception
A template method which must be overridden by the subclass. This method is called instead the struts execute method and if the event comes not from a form or control

Parameters:
ctx - ActionContext
Throws:
java.lang.Exception - if an exception occurs

doSetMenuContext

public void doSetMenuContext(ActionContext ctx,
                             MenuContext menuCtx)
                      throws java.lang.Exception
Sets the menu context. If used, the processing must be implemented in the subclass

Parameters:
ctx - The ActionContext
menuCtx - The MenuContext
Throws:
java.lang.Exception - If an exception occurred

doRenderAjaxResponse

public void doRenderAjaxResponse(ActionContext ctx,
                                 javax.servlet.jsp.PageContext pageContext)
                          throws java.lang.Exception
Renders the AJAX XML response

Parameters:
ctx - ActionContext
pageContext - PageContext
Throws:
java.lang.Exception - Indicates an error during rendering


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.