Class ViewLifecycle
- All Implemented Interfaces:
Serializable
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classRegistration of an event.static enumEnumerates potential lifecycle events. -
Method Summary
Modifier and TypeMethodDescriptionstatic ViewPostMetadatabuildView(View view, Object model, javax.servlet.http.HttpServletRequest request, Map<String, String> parameters) Executes the view lifecycle on the givenViewinstance which will prepare it for renderingstatic voidencapsulateLifecycle(View view, Object model, javax.servlet.http.HttpServletRequest request, Runnable lifecycleProcess) Encapsulate a new view lifecycle process on the current thread.static voidencapsulateLifecycle(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 ViewLifecycleGets the view context active on the current thread.static ExpressionEvaluatorReturn an instance ofExpressionEvaluatorthat can be used for evaluating expressions contained on the viewstatic ViewHelperServiceGets the helper active within a lifecycle on the current thread.static ObjectgetModel()Gets the model related to the view active within this context.static ViewLifecyclePhasegetPhase()Gets the current phase of the active lifecycle, or null if no phase is currently active.static ViewLifecycleProcessorGets the lifecycle processor active on the current thread.static StringId of the component to refresh.static StringgetRefreshComponentPhasePath(String viewPhase) When a refresh lifecycle is being processed, returns the phase path (path at the current phase) for the component being refreshed.static ComponentPostMetadataWhen the lifecycle is processing a component refresh, returns aComponentPostMetadatainstance for the component being refresh.static LifecycleRenderingContextGets the rendering context for this lifecycle.static javax.servlet.http.HttpServletRequestGets the servlet request for this lifecycle.static ViewgetView()Gets the view active within a lifecycle on the current thread.static ViewPostMetadataReturns the view post metadata instance associated with the view and lifecycle.Gets the set of visited IDs for use during the apply model phase.voidinvokeEventListeners(ViewLifecycle.LifecycleEvent event, View view, Object model, LifecycleElement eventElement) Invoked when an event occurs to invoke registered listeners.static booleanisActive()Determine if a lifecycle processor is active on the current thread.static booleanDetermines whether or not to processing view lifecycle phases asynchronously.static booleanisRefreshComponent(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 booleanIndicates whether the lifecycle is processing a component refresh.static booleanDetermines whether or not to enable rendering within the lifecycle.static booleanisStrict()Determines whether or not the lifecycle is operating in strict mode.static booleanisTrace()Determines whether or not to log trace details for troubleshooting lifecycle phases.static ComponentperformComponentLifecycle(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 voidpreProcess(View view) Performs preliminary processing on a view, prior to caching.voidregisterLifecycleCompleteListener(Component eventComponent, LifecycleEventListener listenerComponent) Registers the given component as a listener for the lifecycle complete event for the given event component.static voidreportIllegalState(String message) Report an illegal state in the view lifecycle.static voidreportIllegalState(String message, Throwable cause) Report an illegal state in the view lifecycle.static voidprotected static voidsetupStandaloneComponentForRefresh(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.
-
Method Details
-
encapsulateLifecycle
public static void encapsulateLifecycle(View view, Object model, javax.servlet.http.HttpServletRequest request, Runnable lifecycleProcess) Encapsulate a new view lifecycle process on the current thread.- Parameters:
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.
-
encapsulateLifecycle
public 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.- Parameters:
lifecycleProcess- The lifecycle process to encapsulate.
-
preProcess
Performs preliminary processing on a view, prior to caching.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.
- Parameters:
view- view to preprocess
-
buildView
public static ViewPostMetadata buildView(View view, Object model, javax.servlet.http.HttpServletRequest request, Map<String, String> parameters) Executes the view lifecycle on the givenViewinstance which will prepare it for renderingAny 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).
- Parameters:
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 theView, 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 out
-
performComponentLifecycle
public 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.- Parameters:
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 view- Returns:
- component instance the lifecycle has been run on
-
setupStandaloneComponentForRefresh
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.- Parameters:
view- view instance the component should be attached tocomponentId- id for the component the lifecycle should be run oncomponentPostMetadata- post metadata instance for the component
-
isRefreshComponent
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).- Returns:
- boolean true if the component is being refreshed, false if not
-
getRefreshComponentPhasePath
When a refresh lifecycle is being processed, returns the phase path (path at the current phase) for the component being refreshed.- Returns:
- path for refresh component at this phase, or null if this is not a refresh lifecycle
-
invokeEventListeners
public void invokeEventListeners(ViewLifecycle.LifecycleEvent event, View view, Object model, LifecycleElement eventElement) Invoked when an event occurs to invoke registered listeners.- Parameters:
event- event that has occurredview- view instance the lifecycle is being executed formodel- object containing the model dataeventElement- component instance the event occurred on/for- See Also:
-
registerLifecycleCompleteListener
public void registerLifecycleCompleteListener(Component eventComponent, LifecycleEventListener listenerComponent) Registers the given component as a listener for the lifecycle complete event for the given event component.The
ViewLifecycle.LifecycleEvent.LIFECYCLE_COMPLETEis 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)- Parameters:
eventComponent- component the event will occur forlistenerComponent- component to invoke when the event is thrown- See Also:
-
isStrict
public static boolean isStrict()Determines whether or not the lifecycle is operating in strict mode.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 phaseIllegalStateExceptionwill 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.
- Returns:
- true for strict operation, false to treat lifecycle violations as warnings
-
isRenderInLifecycle
public static boolean isRenderInLifecycle()Determines whether or not to enable rendering within the lifecycle.This value is controlled by the configuration parameter "krad.uif.lifecycle.render".
- Returns:
- true for rendering within the lifecycle, false if all rendering should be deferred for Spring view processing
-
isAsynchronousLifecycle
public static boolean isAsynchronousLifecycle()Determines whether or not to processing view lifecycle phases asynchronously.This value is controlled by the configuration parameter "krad.uif.lifecycle.asynchronous".
- Returns:
- true if view lifecycle phases should be performed asynchronously, false for synchronous operation
-
isTrace
public static boolean isTrace()Determines whether or not to log trace details for troubleshooting lifecycle phases.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".
- Returns:
- true if view lifecycle phase processing information should be logged
-
reportIllegalState
Report an illegal state in the view lifecycle.When
isStrict()returns true,IllegalStateExceptionwill be thrown. Otherwise, a warning will be logged.- Parameters:
message- The message describing the illegal state.- Throws:
IllegalStateException- If strict mode is enabled.
-
reportIllegalState
Report an illegal state in the view lifecycle.When
isStrict()returns true,IllegalStateExceptionwill be thrown. Otherwise, a warning will be logged.- Parameters:
message- The message describing the illegal state.cause- The (potential) cause of the illegal state.- Throws:
IllegalStateException- If strict mode is enabled.
-
getHelper
Gets the helper active within a lifecycle on the current thread.- Returns:
- helper active on the current thread
-
getView
Gets the view active within a lifecycle on the current thread.- Returns:
- view active on the current thread
-
getExpressionEvaluator
Return an instance ofExpressionEvaluatorthat can be used for evaluating expressions contained on the viewA 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
- Returns:
- instance of ExpressionEvaluator
-
getModel
Gets the model related to the view active within this context.- Returns:
- model related to the view active within this context
-
getVisitedIds
Gets the set of visited IDs for use during the apply model phase.- Returns:
- The set of visited IDs for use during the apply model phase.
-
getViewPostMetadata
Returns the view post metadata instance associated with the view and lifecycle.- Returns:
- view post metadata instance
-
getRefreshComponentPostMetadata
When the lifecycle is processing a component refresh, returns aComponentPostMetadatainstance for the component being refresh.- Returns:
- post metadata for the component being refreshed
-
isRefreshLifecycle
public static boolean isRefreshLifecycle()Indicates whether the lifecycle is processing a component refresh.- Returns:
- boolean true if the lifecycle is refreshing a component, false for the full lifecycle
-
getRequest
public static javax.servlet.http.HttpServletRequest getRequest()Gets the servlet request for this lifecycle.- Returns:
- servlet request for this lifecycle
-
getPhase
Gets the current phase of the active lifecycle, or null if no phase is currently active.- Returns:
- current phase of the active lifecycle
-
getRenderingContext
Gets the rendering context for this lifecycle.- Returns:
- rendering context for this lifecycle
-
getProcessor
Gets the lifecycle processor active on the current thread.- Returns:
- lifecycle processor active on the current thread
-
getActiveLifecycle
Gets the view context active on the current thread.- Returns:
- view context active on the current thread
-
isActive
public static boolean isActive()Determine if a lifecycle processor is active on the current thread.- Returns:
- True if a lifecycle processor is active on the current thread.
-
getRefreshComponentId
Id of the component to refresh. -
setRefreshComponentId
- See Also:
-