public class ViewLifecycle extends Object implements Serializable
LifecycleEventListener
,
Serialized FormModifier and Type | Class and Description |
---|---|
protected class |
ViewLifecycle.EventRegistration
Registration of an event.
|
static class |
ViewLifecycle.LifecycleEvent
Enumerates potential lifecycle events.
|
Modifier and Type | Method and Description |
---|---|
static ViewPostMetadata |
buildView(View view,
Object model,
javax.servlet.http.HttpServletRequest request,
Map<String,String> parameters)
Executes the view lifecycle on the given
View instance which will prepare it for
rendering |
static void |
encapsulateLifecycle(View view,
Object model,
javax.servlet.http.HttpServletRequest request,
Runnable lifecycleProcess)
Encapsulate a new view lifecycle process on the current thread.
|
static void |
encapsulateLifecycle(View view,
Object model,
ViewPostMetadata viewPostMetadata,
ComponentPostMetadata refreshComponentPostMetadata,
javax.servlet.http.HttpServletRequest request,
Runnable lifecycleProcess)
Encapsulate a new view lifecycle process on the current thread.
|
static ViewLifecycle |
getActiveLifecycle()
Gets the view context active on the current thread.
|
static ExpressionEvaluator |
getExpressionEvaluator()
Return an instance of
ExpressionEvaluator that can be used for evaluating
expressions contained on the view |
static ViewHelperService |
getHelper()
Gets the helper active within a lifecycle on the current thread.
|
static Object |
getModel()
Gets the model related to the view active within this context.
|
static ViewLifecyclePhase |
getPhase()
Gets the current phase of the active lifecycle, or null if no phase is currently active.
|
static ViewLifecycleProcessor |
getProcessor()
Gets the lifecycle processor active on the current thread.
|
static String |
getRefreshComponentPhasePath(String viewPhase)
When a refresh lifecycle is being processed, returns the phase path (path at the current phase) for
the component being refreshed.
|
static ComponentPostMetadata |
getRefreshComponentPostMetadata()
When the lifecycle is processing a component refresh, returns a
ComponentPostMetadata instance for the component being
refresh. |
static LifecycleRenderingContext |
getRenderingContext()
Gets the rendering context for this lifecycle.
|
static javax.servlet.http.HttpServletRequest |
getRequest()
Gets the servlet request for this lifecycle.
|
static View |
getView()
Gets the view active within a lifecycle on the current thread.
|
static ViewPostMetadata |
getViewPostMetadata()
Returns the view post metadata instance associated with the view and lifecycle.
|
static Set<String> |
getVisitedIds()
Gets the set of visited IDs for use during the apply model phase.
|
void |
invokeEventListeners(ViewLifecycle.LifecycleEvent event,
View view,
Object model,
LifecycleElement eventElement)
Invoked when an event occurs to invoke registered listeners.
|
static boolean |
isActive()
Determine if a lifecycle processor is active on the current thread.
|
static boolean |
isAsynchronousLifecycle()
Determines whether or not to processing view lifecycle phases asynchronously.
|
static boolean |
isRefreshComponent(String viewPhase,
String viewPath)
Indicates if the component the phase is being run on is a component being refreshed (if this is a full
lifecycle this method will always return false).
|
static boolean |
isRefreshLifecycle()
Indicates whether the lifecycle is processing a component refresh.
|
static boolean |
isRenderInLifecycle()
Determines whether or not to enable rendering within the lifecycle.
|
static boolean |
isStrict()
Determines whether or not the lifecycle is operating in strict mode.
|
static boolean |
isTrace()
Determines whether or not to log trace details for troubleshooting lifecycle phases.
|
static Component |
performComponentLifecycle(View view,
Object model,
javax.servlet.http.HttpServletRequest request,
ViewPostMetadata viewPostMetadata,
String componentId)
Performs a lifecycle process to rebuild the component given by the update id.
|
static void |
preProcess(View view)
Performs preliminary processing on a view, prior to caching.
|
void |
registerLifecycleCompleteListener(Component eventComponent,
LifecycleEventListener listenerComponent)
Registers the given component as a listener for the lifecycle complete event for the given
event component.
|
static void |
reportIllegalState(String message)
Report an illegal state in the view lifecycle.
|
static void |
reportIllegalState(String message,
Throwable cause)
Report an illegal state in the view lifecycle.
|
protected static void |
setupStandaloneComponentForRefresh(View view,
String componentId,
ComponentPostMetadata componentPostMetadata)
Before running the lifecycle on a component that is not attached to a view, we need to retrieve the component,
add it to the dialogs list, and setup its refresh paths.
|
public static void encapsulateLifecycle(View view, Object model, javax.servlet.http.HttpServletRequest request, Runnable lifecycleProcess)
view
- The view to perform lifecycle processing on.model
- The model associated with the view.request
- The active servlet request.lifecycleProcess
- The lifecycle process to encapsulate.public static void encapsulateLifecycle(View view, Object model, ViewPostMetadata viewPostMetadata, ComponentPostMetadata refreshComponentPostMetadata, javax.servlet.http.HttpServletRequest request, Runnable lifecycleProcess)
lifecycleProcess
- The lifecycle process to encapsulate.public static void preProcess(View view)
Logic evaluated at this preliminary phase result in global modifications to the view's subcomponents, so this method can be used apply additional logic to the View that is both pre-evaluated and shared by all instances of the component.
view
- view to preprocesspublic static ViewPostMetadata buildView(View view, Object model, javax.servlet.http.HttpServletRequest request, Map<String,String> parameters)
View
instance which will prepare it for
rendering
Any configuration sent through the options Map is used to initialize the View. This map contains present options the view is aware of and will typically come from request parameters. e.g. For maintenance Views there is the maintenance type option (new, edit, copy)
After view retrieval, applies updates to the view based on the model data which Performs dynamic generation of fields (such as collection rows), conditional logic, and state updating (conditional hidden, read-only, required).
view
- view instance that should be builtmodel
- object instance containing the view datarequest
- The active servlet request.parameters
- - Map of key values pairs that provide configuration for the
View
, this is generally comes from the request and can be the request
parameter Map itself. Any parameters not valid for the View will be filtered outpublic static Component performComponentLifecycle(View view, Object model, javax.servlet.http.HttpServletRequest request, ViewPostMetadata viewPostMetadata, String componentId)
view
- view instance the component belongs tomodel
- object containing the full view datarequest
- The active servlet request.viewPostMetadata
- post metadata for the viewcomponentId
- id of the component within the view, used to pull the current component from the viewprotected static void setupStandaloneComponentForRefresh(View view, String componentId, ComponentPostMetadata componentPostMetadata)
view
- view instance the component should be attached tocomponentId
- id for the component the lifecycle should be run oncomponentPostMetadata
- post metadata instance for the componentpublic static boolean isRefreshComponent(String viewPhase, String viewPath)
public static String getRefreshComponentPhasePath(String viewPhase)
public void invokeEventListeners(ViewLifecycle.LifecycleEvent event, View view, Object model, LifecycleElement eventElement)
event
- event that has occurredview
- view instance the lifecycle is being executed formodel
- object containing the model dataeventElement
- component instance the event occurred on/forViewLifecycle.LifecycleEvent
public void registerLifecycleCompleteListener(Component eventComponent, LifecycleEventListener listenerComponent)
The ViewLifecycle.LifecycleEvent.LIFECYCLE_COMPLETE
is thrown immediately after the finalize phase
has been completed for a component. This can be useful if a component needs to set state
after the lifecycle has been completed on another component (for example, it might depend on
properties of that component that are set during the finalize phase of that component)
eventComponent
- component the event will occur forlistenerComponent
- component to invoke when the event is thrownViewLifecycle.LifecycleEvent
,
LifecycleEventListener
public static boolean isStrict()
LifecycleElement.getViewStatus()
is checked at the beginning and end of each lifecycle
phase. When operating in strict mode, when a component is in the wrong status for the current
phase IllegalStateException
will be thrown. When not in strict mode, warning messages
are logged on the console.
This value is controlled by the configuration parameter "krad.uif.lifecycle.strict". In Rice 2.4, the view lifecycle is *not* strict by default.
public static boolean isRenderInLifecycle()
This value is controlled by the configuration parameter "krad.uif.lifecycle.render".
public static boolean isAsynchronousLifecycle()
This value is controlled by the configuration parameter "krad.uif.lifecycle.asynchronous".
public static boolean isTrace()
View lifecycle tracing is very verbose. This feature should only be enabled for troubleshooting purposes.
This value is controlled by the configuration parameter "krad.uif.lifecycle.trace".
public static void reportIllegalState(String message)
When isStrict()
returns true, IllegalStateException
will be thrown.
Otherwise, a warning will be logged.
message
- The message describing the illegal state.IllegalStateException
- If strict mode is enabled.public static void reportIllegalState(String message, Throwable cause)
When isStrict()
returns true, IllegalStateException
will be thrown.
Otherwise, a warning will be logged.
message
- The message describing the illegal state.cause
- The (potential) cause of the illegal state.IllegalStateException
- If strict mode is enabled.public static ViewHelperService getHelper()
public static View getView()
public static ExpressionEvaluator getExpressionEvaluator()
ExpressionEvaluator
that can be used for evaluating
expressions contained on the view
A ExpressionEvaluator must be initialized with a model for expression evaluation. One instance is constructed for the view lifecycle and made available to all components/helpers through this method
public static Object getModel()
public static Set<String> getVisitedIds()
public static ViewPostMetadata getViewPostMetadata()
public static ComponentPostMetadata getRefreshComponentPostMetadata()
ComponentPostMetadata
instance for the component being
refresh.public static boolean isRefreshLifecycle()
public static javax.servlet.http.HttpServletRequest getRequest()
public static ViewLifecyclePhase getPhase()
public static LifecycleRenderingContext getRenderingContext()
public static ViewLifecycleProcessor getProcessor()
public static ViewLifecycle getActiveLifecycle()
public static boolean isActive()
Copyright © 2005–2014 The Kuali Foundation. All rights reserved.