Oracle Fusion Middleware Java API Reference for Oracle ADF Lifecycle
11g Release 1 (11.1.1.4.0)

E10652-05

oracle.adf.controller.v2.lifecycle
Class PageLifecycleImpl

java.lang.Object
  extended by oracle.adf.controller.v2.lifecycle.Phases
      extended by oracle.adf.controller.v2.lifecycle.PageLifecycle
          extended by oracle.adf.controller.v2.lifecycle.PageLifecycleImpl
Direct Known Subclasses:
StrutsPageLifecycle

public class PageLifecycleImpl
extends PageLifecycle

Implementation of the PageLifecycle abstract class.

This contain the base implementation of the Phases of the ADF Lifecycle.

Since:
10.1.3

Field Summary
static java.lang.String DISABLE_VALIDATE_TOKENS
          A request-level property used to disable the token validation.
static java.lang.String ordDomainInputHandlerName
          A custom input handler used by bindings dealing with ord domain type.
 
Fields inherited from class oracle.adf.controller.v2.lifecycle.PageLifecycle
clazz, eventParam, events
 
Constructor Summary
PageLifecycleImpl()
           
 
Method Summary
 void applyInputValues(LifecycleContext lfContext)
          Builds the list of events with their possible associated action binding from the request parameters.
protected  void buildEventList(PageLifecycleContext context)
          Possible events are request parameters named "event" or which name are prefixed with "event_".
protected  void buildInputValues(PageLifecycleContext context)
          Build a list of all the new submited ADF values from the request parameters.
protected  void disableTokenValidationForRequest(PageLifecycleContext context)
          Token validation will only occur once-per-request.
 void executeEvent(PageLifecycleContext context, java.lang.String event, oracle.adf.model.OperationBinding actionBinding)
          Execute a single event.
protected  oracle.adf.model.ControlBinding findCtrlBinding(oracle.adf.model.RegionBinding bindings, java.lang.String event)
          Look action binding with the name 'name' or 'Name'
 void findForward(PageLifecycleContext context)
          The path of the next web page is identified using the forwardPath property on the PageLifecycleContext.
 java.lang.reflect.Method getEventMethod(PageLifecycleContext lcContext, java.lang.String eventName)
          Retrieve the Method class for a given an event name.
protected  java.lang.String getToken(PageLifecycleContext context, oracle.adf.model.RegionBinding bindings)
          Retrieve the token from the request
 void handleError(PageLifecycleContext context, java.lang.Exception ex)
          Handles any exceptions that occurred during the PageLifecycle processing.
protected  boolean handleEvent(PageLifecycleContext context, java.lang.String event)
          Handle an event.
 boolean hasErrors(PageLifecycleContext context)
          Return true if an error occured during validation.
 void initContext(LifecycleContext lfContext)
          During this phase the listener is able to initialize the LifecycleContext with additional information that will be persisted during the Lifecycle.
 void initializeMethodParameters(PageLifecycleContext context, oracle.adf.model.OperationBinding actionBinding)
          This method is invoked before any ControlBinding or custom method is being executed.
protected  void initializeParameterValuesUsingRequestObject(PageLifecycleContext context, oracle.adf.model.OperationBinding actionBinding)
          In model 1 we do not have a way to initialize method parameters.
 boolean invokeActionBinding(PageLifecycleContext context, java.lang.String event)
          Invoke the action binding associated with the event name.
 boolean invokeEventMethod(PageLifecycleContext lcContext, java.lang.String eventName)
          Execute the Method class for a given an event name.
protected  boolean isRecoverableException(java.lang.Exception ex)
          Determine if the exception can be handled by ADF or should thrown right away.
 void metadataCommit(LifecycleContext lfContext)
          Used to commit Runtime changes to the metadata.
 void prepareModel(LifecycleContext lfContext)
          Give the opportunity for the data model to prepare and initialize.
 void prepareRender(LifecycleContext lfContext)
          Last phase before rendering a page.
 void processComponentEvents(LifecycleContext lfContext)
          Process each event accumulated during the previous phases.
protected  void processEvent(PageLifecycleContext context, java.lang.String event)
          Process a possible raw event coming as a request parameter.
 void processUpdateModel(LifecycleContext lfContext)
          Update the data model with new and validated input values.
protected  void registerCustomInputHandler(PageLifecycleContext context)
          Register OrdDomainInputHandler custom input handler to the binding context.
 void reportErrors(PageLifecycleContext context)
          Provide the opportunity to build an error list in a format appropriate to the view layer.
 boolean shouldAllowModelUpdate(PageLifecycleContext context)
          This method is called during the processUpdateModel phase.
protected  boolean shouldValidateToken(PageLifecycleContext context, oracle.adf.model.RegionBinding bindings)
          Checks the request object to see if token validation should occur.
 void validateInputValues(LifecycleContext lfContext)
          Validate input values.
 void validateModelUpdates(LifecycleContext lfContext)
          Forces model-level validation to occur.
 
Methods inherited from class oracle.adf.controller.v2.lifecycle.PageLifecycle
getEventMethodFromCache, getLifecycleContextClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISABLE_VALIDATE_TOKENS

public static final java.lang.String DISABLE_VALIDATE_TOKENS
A request-level property used to disable the token validation. Token validation should only occur once per http request.

See Also:
Constant Field Values

ordDomainInputHandlerName

public static final java.lang.String ordDomainInputHandlerName
A custom input handler used by bindings dealing with ord domain type.

See Also:
Constant Field Values
Constructor Detail

PageLifecycleImpl

public PageLifecycleImpl()
Method Detail

initContext

public void initContext(LifecycleContext lfContext)
Description copied from class: Phases
During this phase the listener is able to initialize the LifecycleContext with additional information that will be persisted during the Lifecycle.

Specified by:
initContext in class Phases

prepareModel

public void prepareModel(LifecycleContext lfContext)
Give the opportunity for the data model to prepare and initialize.

If you need to reference prepared model values and/or update the values of any bindings in the binding container, then you can do it by overriding this method and doing it after calling the superclass.

Specified by:
prepareModel in class Phases

applyInputValues

public void applyInputValues(LifecycleContext lfContext)
Builds the list of events with their possible associated action binding from the request parameters. In this method, the input values list and the event list are built.

Specified by:
applyInputValues in class Phases

validateInputValues

public void validateInputValues(LifecycleContext lfContext)
Description copied from class: Phases
Validate input values.

Specified by:
validateInputValues in class Phases

processUpdateModel

public void processUpdateModel(LifecycleContext lfContext)
Update the data model with new and validated input values.

This phase is executed only if the shouldAllowModelUpdate method returns true.

In case of error when setting the value to the model the errors will not be thrown but collected in the binding container.

Specified by:
processUpdateModel in class Phases

shouldAllowModelUpdate

public boolean shouldAllowModelUpdate(PageLifecycleContext context)
Description copied from class: PageLifecycle
This method is called during the processUpdateModel phase. It provides a way to programmatically by-pass model updates. The data model updates are disabled when specific action like 'rollback' will be executed during the lifecycle. This is done by calling the ignoreUpdates method or each action in the event list. The custom method ignoreUpdates is also called. Bypassing update might be necessary for operations such as rollback or custom methods that want to veto the change.
Overide this method if you need to add logic to skip data model updates.

Specified by:
shouldAllowModelUpdate in class PageLifecycle
See Also:
JUCtrlActionBinding.ignoreUpdates()

validateModelUpdates

public void validateModelUpdates(LifecycleContext lfContext)
Forces model-level validation to occur.

This phase is executed only if the shouldAllowModelUpdate method returns true.

To delay model-level validation until Commit, override this method and replace it with a no-op.

Specified by:
validateModelUpdates in class Phases

processComponentEvents

public void processComponentEvents(LifecycleContext lfContext)
Process each event accumulated during the previous phases. Handle any events in the Events list previously built during the applyInputValues phase.

Specified by:
processComponentEvents in class Phases

executeEvent

public void executeEvent(PageLifecycleContext context,
                         java.lang.String event,
                         oracle.adf.model.OperationBinding actionBinding)
Description copied from class: PageLifecycle
Execute a single event.

Specified by:
executeEvent in class PageLifecycle
See Also:
handleEvent.

hasErrors

public boolean hasErrors(PageLifecycleContext context)
Return true if an error occured during validation. The default implementation looks at the content of the ExceptionList of the BindingContainer to determine if an error occured.

Specified by:
hasErrors in class PageLifecycle

initializeParameterValuesUsingRequestObject

protected void initializeParameterValuesUsingRequestObject(PageLifecycleContext context,
                                                           oracle.adf.model.OperationBinding actionBinding)
In model 1 we do not have a way to initialize method parameters. In the action binding the user can change the name of the parameters. This function will iterate through the parameter names in the action binding and look for request parameters that match those names. This transfer of values allows us to pass in request parameters that match the action binding's parameter names.

Parameters:
context - the Pagelifecycle context
actionBinding - the action binding to initialize

initializeMethodParameters

public void initializeMethodParameters(PageLifecycleContext context,
                                       oracle.adf.model.OperationBinding actionBinding)
Description copied from class: PageLifecycle
This method is invoked before any ControlBinding or custom method is being executed. Overriding this method gives an opportunity to set the parameters.

Specified by:
initializeMethodParameters in class PageLifecycle
Parameters:
context - the PageLifecycle context
actionBinding - the action binding object to initialize

metadataCommit

public void metadataCommit(LifecycleContext lfContext)
Description copied from class: Phases
Used to commit Runtime changes to the metadata. This phase is always called before prepareRender even in case of navigation.

Specified by:
metadataCommit in class Phases

prepareRender

public void prepareRender(LifecycleContext lfContext)
Description copied from class: Phases
Last phase before rendering a page. This can be used to notify a binding that rendering is about to happen and allow them to optimize data preparation or processing before the rendering begins.

During this phase the model is refreshed.

Specified by:
prepareRender in class Phases

isRecoverableException

protected boolean isRecoverableException(java.lang.Exception ex)
Determine if the exception can be handled by ADF or should thrown right away.

Parameters:
ex -
Returns:

handleError

public void handleError(PageLifecycleContext context,
                        java.lang.Exception ex)
Description copied from class: PageLifecycle
Handles any exceptions that occurred during the PageLifecycle processing. Clients have an opportunity to merge the exception with the model errors stored in the BindingContainer.

Specified by:
handleError in class PageLifecycle

reportErrors

public void reportErrors(PageLifecycleContext context)
Description copied from class: PageLifecycle
Provide the opportunity to build an error list in a format appropriate to the view layer.

Specified by:
reportErrors in class PageLifecycle

getToken

protected java.lang.String getToken(PageLifecycleContext context,
                                    oracle.adf.model.RegionBinding bindings)
Retrieve the token from the request


shouldValidateToken

protected boolean shouldValidateToken(PageLifecycleContext context,
                                      oracle.adf.model.RegionBinding bindings)
Checks the request object to see if token validation should occur.


disableTokenValidationForRequest

protected void disableTokenValidationForRequest(PageLifecycleContext context)
Token validation will only occur once-per-request. This function will disable token validation for the given request.

See Also:
DISABLE_VALIDATE_TOKENS

processEvent

protected void processEvent(PageLifecycleContext context,
                            java.lang.String event)
Process a possible raw event coming as a request parameter. This method handle the case where the request parameter is produced from an image control where the parameter name represent the coordinate of the mouse when clicked on the image. This also make sure an event is not executed multiple time when the request is forwarded.

Parameters:
context - the Pagelifecycle context
event - the event name

findCtrlBinding

protected oracle.adf.model.ControlBinding findCtrlBinding(oracle.adf.model.RegionBinding bindings,
                                                          java.lang.String event)
Look action binding with the name 'name' or 'Name'

Parameters:
bindings - the binding container
event - the event name

buildInputValues

protected void buildInputValues(PageLifecycleContext context)

Build a list of all the new submited ADF values from the request parameters.

The result is a Map of values keyed by binding instance stored in the UpdatedValues property.
Only new values are kept in the UpdatedValues list.

Parameters:
context - the Pagelifecycle context

buildEventList

protected void buildEventList(PageLifecycleContext context)
Possible events are request parameters named "event" or which name are prefixed with "event_". If there are parameters named "event" each of their values are event names. If the parameter name starts with "event_", the following part of the name is the event name. (i.e "event_Next" will add the event called "Next").

The "event" prefix can be modified using setEventPrefix

By doing this once and storing the result in the lifecycle context we don't have to walk through the request parameter list multiple time during the lifecycle.

See Also:
addControlActionBinding, getControlActionBindings, addEvent, getEvents

registerCustomInputHandler

protected void registerCustomInputHandler(PageLifecycleContext context)
Register OrdDomainInputHandler custom input handler to the binding context.


handleEvent

protected boolean handleEvent(PageLifecycleContext context,
                              java.lang.String event)
                       throws java.lang.Exception
Handle an event. An event handler can be a method defined in a subclass of this PageLifecycle. To be recognized as an event handle the method need to have the following syntax:
 public void onEvent(LifecycleContext ctx)
 {
    // Use the following method to execute the possible
    // action binding associated with this event
    ctx.getEventActionBinding().invoke();
 }
 
Where Event is the name of the event.

An event can also be an action binding with the same name of the event present in the current binding container.

Parameters:
context - the PageLifecycle context
event - the name of the event to handle
Returns:
true if the event was mapped to an action binding
Throws:
java.lang.Exception
See Also:
buildEventList, PageLifecycleContext.EVENT_METHOD_PREFIX

getEventMethod

public java.lang.reflect.Method getEventMethod(PageLifecycleContext lcContext,
                                               java.lang.String eventName)
Description copied from class: PageLifecycle
Retrieve the Method class for a given an event name.

Parameters:
lcContext - the PageLifecycle context
eventName - name of the event
Returns:
the Method object for this event if exist

invokeEventMethod

public boolean invokeEventMethod(PageLifecycleContext lcContext,
                                 java.lang.String eventName)
                          throws java.lang.Exception
Description copied from class: PageLifecycle
Execute the Method class for a given an event name.

Parameters:
lcContext - the PageLifecycle context
eventName - name of the event
Returns:
the Method object for this event if exist
Throws:
java.lang.Exception

invokeActionBinding

public boolean invokeActionBinding(PageLifecycleContext context,
                                   java.lang.String event)
Description copied from class: PageLifecycle
Invoke the action binding associated with the event name.

An action binding is associated with an event if an action binding with the same name as the event exist in the current binding container. If the action binding exist, the method parameters are initialized using the initializeMethodParameters method on the PageLifecycle before executing the action binding.


If the action binding exist the method return true

Parameters:
context - the lifecycle context
event - the name of the event
Returns:
true if an action binding is associated with the event

findForward

public void findForward(PageLifecycleContext context)
                 throws java.lang.Exception
Description copied from class: PageLifecycle
The path of the next web page is identified using the forwardPath property on the PageLifecycleContext. If the redirect property on the PageLifecycleContext is true, the response will be redirected to the specified path. Otherwise, the request will be forwarded to the specified path.

Specified by:
findForward in class PageLifecycle
Throws:
java.lang.Exception

Oracle Fusion Middleware Java API Reference for Oracle ADF Lifecycle
11g Release 1 (11.1.1.4.0)

E10652-05

Copyright © 1997, 2011, Oracle. All rights reserved.