Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Oracle Application Development Framework Controller Java API Reference 10g Release 3 (10.1.3) B16004-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.adf.controller.lifecycle
Class PageLifecycle

`java.lang.Object
oracle.adf.controller.lifecycle.PageLifecycle`

All Implemented Interfaces:
  Lifecycle

Direct Known Subclasses:
  StrutsPageLifecycle

public class PageLifecycle
extends java.lang.Object
implements Lifecycle

Implementation of the Lifecycle for web pages. It provide the base functionality that is extended when used with a controller like Jakarta Struts. See `StrutsPageLifecycle`.

When used without a controller, each JSP require to add a tag

    <adf:uimodelreference model="pageUIModel" />

at the top of the page to bootstrap the page lifecycle and define the binding container associated with the page.

Since:
  9.0.5

Field Summary
`protected java.lang.Class` | `clazz` The Class instance for this class (PageLifecycle).
`static java.lang.String` | `DISABLE_VALIDATE_TOKENS` A request-level property used to disable the token validation.
`protected java.lang.Class[]` | `eventParam` The set of argument type classes for the reflected event method call.
`protected java.util.Map` | `events` Cache the set of event methods as they are introspected.
`static java.lang.String` | `ordDomainInputHandlerName` A custom input handler used by bindings dealing with ord domain type

Constructor Summary
`PageLifecycle()`

Method Summary
`void` | `buildEventList(LifecycleContext lcContext)` Builds the list of events with their possible associated action binding from the request parameters. Possible events are request parameters named "event" or which name are prefixed with "event_".
`protected void` | `disableTokenValidationForRequest(javax.servlet.http.HttpServletRequest request)` Token validation will only occur once-per-request.
`protected oracle.adf.model.binding.DCControlBinding` | `findCtrlBinding(oracle.adf.model.binding.DCBindingContainer bindings, java.lang.String event)` Look action binding with the name 'name' or 'Name'
`void` | `findForward(LifecycleContext lcContext)` Forwards the request or redirects the response to the next web page in the flow..
`java.lang.reflect.Method` | `getEventMethod(LifecycleContext lcContext, java.lang.String name)` Retrieve the Method class for an event name.
`static java.lang.reflect.Method` | `getEventMethodFromCache(java.util.Map events, java.lang.Class clazz, java.lang.Class[] eventParams, java.lang.String eventName)` Internal
`protected java.util.Map` | `getRequestValues(LifecycleContext lcContext)` Returns all the submited ADF values from the request parameters.
`void` | `handleError(LifecycleContext lcContext, java.lang.Exception ex)` Handles any exceptions that occurred during the Lifecycle processing..
`protected boolean` | `handleEvent(LifecycleContext lcContext, java.lang.String event)` Handle an event.
`void` | `handleLifecycle(LifecycleContext lcContext)` Define all the phases of the lifecycle and the order they are executed..
`boolean` | `hasErrors(LifecycleContext lcContext)` Ask the context if any errors have been recorded during this lifecycle.
`void` | `initializeMethodParameters(LifecycleContext lcContext, oracle.jbo.uicli.binding.JUCtrlActionBinding actionBinding)` This method is invoked before any ControlBinding or custom method is being executed.
`protected void` | `initializeParameterValuesUsingRequestObject(LifecycleContext lcContext, oracle.jbo.uicli.binding.JUCtrlActionBinding actionBinding)` In model 1 we do not have a way to initialize method parameters.
`boolean` | `invokeActionBinding(LifecycleContext lcContext, java.lang.String event)` Invoke the action binding associated with the event name.
`void` | `invokeCustomMethod(LifecycleContext lcContext)` Invokes the custom method associated with the binding container.
`protected boolean` | `isNewValueForBinding(oracle.jbo.uicli.binding.JUCtrlValueBinding binding, java.lang.Object value)` Deprecated. Use InputHandler.
`void` | `prepareModel(LifecycleContext lcContext)` Give the opportunity for the data model to prepare and initialize. This method will throw if the data model cannot be prepared.
`void` | `processComponentEvents(LifecycleContext lcContext)` Handle any events in the action binding list previously built in processUpdateModel using the buildEventList method.
`protected void` | `processEvent(LifecycleContext lcContext, java.lang.String event)` Process a possible raw event coming as a request parameter.
`void` | `processUpdateModel(LifecycleContext lcContext)` Update the data model with values submitted in the request.
`void` | `refreshModel(LifecycleContext lcContext)` Used to notify the model when updates are over with.
`void` | `reportErrors(LifecycleContext lcContext)` Report the error list to the view layer.
`protected void` | `setInputValue(oracle.jbo.uicli.binding.JUCtrlValueBinding binding, java.lang.Object value)` Deprecated. Use InputHandler.
`boolean` | `shouldAllowModelUpdate(LifecycleContext lcContext)` Allows clients to determine whether the model should be updated..
`protected boolean` | `shouldValidateToken(javax.servlet.http.HttpServletRequest request, oracle.adf.model.binding.DCBindingContainer bindings)` Checks the request object to see if token validation should occur.
`protected void` | `updateModel(LifecycleContext lcContext, java.util.Map updatedValues)` Apply each new values to the binding.
`void` | `validateModelUpdates(LifecycleContext lcContext)` Forces model-level validation to occur. To delay model-level validation until Commit, override this method and replace it with a no-op.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### events

    protected java.util.Map events

  Cache the set of event methods as they are introspected.

### clazz

    protected java.lang.Class clazz

  The Class instance for this class (PageLifecycle).

### eventParam

    protected java.lang.Class[] eventParam

  The set of argument type classes for the reflected event method call.

### 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

### 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

Constructor Detail

### PageLifecycle

    public PageLifecycle()

Method Detail

### handleLifecycle

    public void handleLifecycle(LifecycleContext lcContext)
                         throws java.lang.Exception

  Define all the phases of the lifecycle and the order they are executed.. This is the entry point to execute the all the phases of the lifecycle.
  Overide this method to add logic before or after the lifecycle execution.

  Define the steps of the PageLifecycle processing:

  - prepares the context and build the event list
  - prepare the model for updates
  - process model updates
  - performs validation
  - process component event
  - process custom method
  - handles errors
  Specified by:
    `handleLifecycle` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
  Throws:
    `java.lang.Exception`

### prepareModel

    public void prepareModel(LifecycleContext lcContext)
                      throws java.lang.Exception

  Give the opportunity for the data model to prepare and initialize. This method will throw if the data model cannot be prepared.

  If you need to set bind variable values on query objects in the business services layer in order to properly prepare the model, then you can set them by overriding this method and doing it before calling the superclass.

  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 interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
  Throws:
    `java.lang.Exception`

### disableTokenValidationForRequest

    protected void disableTokenValidationForRequest(javax.servlet.http.HttpServletRequest request)

  Token validation will only occur once-per-request. This function will disable token validation for the given request.
  Parameters:
    `request` -

### shouldValidateToken

    protected boolean shouldValidateToken(javax.servlet.http.HttpServletRequest request,
                                          oracle.adf.model.binding.DCBindingContainer bindings)

  Checks the request object to see if token validation should occur.
  Parameters:
    `request` -
    `bindings` -
  Returns:
    true if token validation should occur

### processUpdateModel

    public void processUpdateModel(LifecycleContext lcContext)

  Update the data model with values submitted in the request.

  Collect the new values from request parameters and update the model with them. Only new values are set to the bindings.

  Specified by:
    `processUpdateModel` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context

### updateModel

    protected void updateModel(LifecycleContext lcContext,
                               java.util.Map updatedValues)

  Apply each new values to the binding. The values are coming from a Map of values keyed by property name. In case of error the method setInputValue will not throw but instead the errors will be collected in the binding container.
  Parameters:
    `lcContext` - the lifecycle context
    `updatedValues` - the map of values keyed by property name
  See Also:
    `getRequestValues(oracle.adf.controller.lifecycle.LifecycleContext)`

### isNewValueForBinding

    protected boolean isNewValueForBinding(oracle.jbo.uicli.binding.JUCtrlValueBinding binding,
                                           java.lang.Object value)

  Deprecated. Use InputHandler.
  Return `true` if the value is different from the current value of the binding.
  Parameters:
    `binding` - the value binding to test
    `value` - the new value for this binding
  Returns:
    `true` if the value is new

### setInputValue

    protected void setInputValue(oracle.jbo.uicli.binding.JUCtrlValueBinding binding,
                                 java.lang.Object value)

  Deprecated. Use InputHandler.
  Sets the value to the binding.
  Parameters:
    `binding` - the binding that will receive the value
    `value` - the value to set to the binding

### getRequestValues

    protected java.util.Map getRequestValues(LifecycleContext lcContext)

  Returns all the submited ADF values from the request parameters. The result is a Map of values keyed by property names.
  Only the request parameters with a specific syntax are reconized as property name for a value binding (see `DCUtil.isValueBindingPath(java.lang.String)`).
  Parameters:
    `lcContext` - the lifecycle context
  Returns:
    a Map of binding names and their new values

### shouldAllowModelUpdate

    public boolean shouldAllowModelUpdate(LifecycleContext lcContext)

  Allows clients to determine whether the model should be updated..

  Disable data model updates in two cases:

  - 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.
  - When the binding container of the previous page does not match. This is to get around the case where updates from the previous page in the forward chain are applied.
  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 interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context.
  Returns:
    `true`, if the model should be updated during this lifecycle
  See Also:
    `JUCtrlActionBinding.ignoreUpdates()`

### validateModelUpdates

    public void validateModelUpdates(LifecycleContext lcContext)

  Forces model-level validation to occur. To delay model-level validation until Commit, override this method and replace it with a no-op.
  Specified by:
    `validateModelUpdates` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context

### processComponentEvents

    public void processComponentEvents(LifecycleContext lcContext)
                                throws java.lang.Exception

  Description copied from interface: `Lifecycle`
  Handle any events in the action binding list previously built in processUpdateModel using the buildEventList method.
  Specified by:
    `processComponentEvents` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
  Throws:
    `java.lang.Exception`

### handleEvent

    protected boolean handleEvent(LifecycleContext lcContext,
                                  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().doit();
       }

  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:
    `lcContext` - the lifecycle 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`, `LifecycleContext.EVENT_METHOD_PREFIX`

### getEventMethod

    public java.lang.reflect.Method getEventMethod(LifecycleContext lcContext,
                                                   java.lang.String name)

  Retrieve the Method class for an event name.
  Specified by:
    `getEventMethod` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
    `name` - name of the event
  Returns:
    the Method object for this event if exist

### initializeParameterValuesUsingRequestObject

    protected void initializeParameterValuesUsingRequestObject(LifecycleContext lcContext,
                                                               oracle.jbo.uicli.binding.JUCtrlActionBinding 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:
    `lcContext` - the lifecycle context
    `actionBinding` - the action binding to initialize

### initializeMethodParameters

    public void initializeMethodParameters(LifecycleContext lcContext,
                                           oracle.jbo.uicli.binding.JUCtrlActionBinding actionBinding)

  Description copied from interface: `Lifecycle`
  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 interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
    `actionBinding` - the action binding object to initialize

### invokeActionBinding

    public boolean invokeActionBinding(LifecycleContext lcContext,
                                       java.lang.String event)

  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 lifecycle before executing the action binding.
  If the action binding exist the method return `true`
  Parameters:
    `lcContext` - the lifecycle context
    `event` - the name of the event
  Returns:
    `true` if an action binding is associated with the event

### invokeCustomMethod

    public void invokeCustomMethod(LifecycleContext lcContext)

  Description copied from interface: `Lifecycle`
  Invokes the custom method associated with the binding container.
  Specified by:
    `invokeCustomMethod` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context

### hasErrors

    public boolean hasErrors(LifecycleContext lcContext)

  Description copied from interface: `Lifecycle`
  Ask the context if any errors have been recorded during this lifecycle.
  Specified by:
    `hasErrors` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
  Returns:
    `true`, if any validation errors have been stored in the LifecycleContext.

### refreshModel

    public void refreshModel(LifecycleContext lcContext)

  Description copied from interface: `Lifecycle`
  Used to notify the model when updates are over with.
  Specified by:
    `refreshModel` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context

### handleError

    public void handleError(LifecycleContext lcContext,
                            java.lang.Exception ex)

  Handles any exceptions that occurred during the Lifecycle processing.. Clients have an opportunity to merge the exception with the model errors stored in the binding container.
  Specified by:
    `handleError` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
    `ex` - the exception to record

### reportErrors

    public void reportErrors(LifecycleContext lcContext)

  Description copied from interface: `Lifecycle`
  Report the error list to the view layer.
  Specified by:
    `reportErrors` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context

### buildEventList

    public void buildEventList(LifecycleContext lcContext)

  Builds the list of events with their possible associated action binding from the request parameters. 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.

  Specified by:
    `buildEventList` in interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
  See Also:
    `addControlActionBinding`, `getControlActionBindings`, `addEvent`, `getEvents`

### processEvent

    protected void processEvent(LifecycleContext lcContext,
                                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:
    `lcContext` - the lifecycle context
    `event` - the event name

### findCtrlBinding

    protected oracle.adf.model.binding.DCControlBinding findCtrlBinding(oracle.adf.model.binding.DCBindingContainer bindings,
                                                                        java.lang.String event)

  Look action binding with the name 'name' or 'Name'
  Parameters:
    `bindings` - the binding container
    `event` - the event name
  Returns:
    the databinding for event, null if not found

### findForward

    public void findForward(LifecycleContext lcContext)
                     throws java.lang.Exception

  Forwards the request or redirects the response to the next web page in the flow.. The path of the next web page is identified using the forwardPath property on the LifecycleContext. If the redirect property on the LifecycleContext 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 interface `Lifecycle`
  Parameters:
    `lcContext` - the lifecycle context
  Throws:
    `java.lang.Exception`

### getEventMethodFromCache

    public static final java.lang.reflect.Method getEventMethodFromCache(java.util.Map events,
                                                                         java.lang.Class clazz,
                                                                         java.lang.Class[] eventParams,
                                                                         java.lang.String eventName)

  Internal

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Oracle Application Development Framework Controller Java API Reference 10g Release 3 (10.1.3) B16004-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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