public class ViewHelperServiceImpl extends Object implements ViewHelperService, Serializable
ViewHelperService
Constructor and Description |
---|
ViewHelperServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addClientSideStateForComponent(Component component,
Map<String,Object> clientSideState)
Reflects the class for the given component to find any fields that are annotated with
ClientSideState and adds the corresponding property name/value pair to the client side state
map |
protected void |
addCustomContainerComponents(View view,
Object model,
Container container)
Hook for creating new components with code and adding them to a container
|
protected void |
applyAuthorizationAndPresentationLogic(View view,
Component component,
ViewModel model)
Invokes the view's configured
ViewAuthorizer and ViewPresentationController to set state of
the component |
protected void |
applyDefaultValues(View view,
Component component,
Object model)
Iterates through the view components picking up data fields and applying an default value configured
|
void |
applyDefaultValuesForCollectionLine(View view,
Object model,
CollectionGroup collectionGroup,
Object line)
Applies configured default values for the line fields to the line
instance
|
protected String |
buildClientSideStateScript(View view,
Map<String,Object> clientSideState,
boolean updateOnly)
Builds script that will initialize configuration parameters and component state on the client
|
void |
buildInquiryLink(Object dataObject,
String propertyName,
Inquiry inquiry)
Finds the
Inquirable configured for the given data object
class and delegates to it for building the inquiry URL |
protected AttributeDefinition |
findNestedDictionaryAttribute(View view,
DataField field,
String parentPath,
String propertyPath)
Recursively drills down the property path (if nested) to find an
AttributeDefinition, the first attribute definition found will be
returned
|
protected Map<String,Object> |
getCommonContext(View view,
Component component)
Gets global objects for the context map and pushes them to the context
for the component
|
protected DataDictionaryService |
getDataDictionaryService() |
protected ExpressionEvaluatorService |
getExpressionEvaluatorService() |
protected Map<String,Object> |
getPreModelContext(View view)
Returns the general context that is available before the apply model
phase (during the initialize phase)
|
ViewDictionaryService |
getViewDictionaryService() |
protected void |
initializeDataFieldFromDataDictionary(View view,
DataField field)
Sets properties of the
InputField (if blank) to the
corresponding attribute entry in the data dictionary |
protected void |
invokeMethodFinalizer(View view,
Component component,
Object model)
Invokes the finalize method for the component (if configured) and sets
the render output for the component to the returned method string (if
method is not a void type)
|
protected void |
logAndThrowRuntime(String message) |
protected boolean |
performAddLineValidation(View view,
CollectionGroup collectionGroup,
Object model,
Object addLine)
Performs validation on the new collection line before it is added to the
corresponding collection
|
void |
performApplyModel(View view,
Object model)
Executes the ApplyModel phase.
|
protected void |
performComponentApplyModel(View view,
Component component,
Object model)
Applies the model data to a component of the View instance
|
protected void |
performComponentFinalize(View view,
Component component,
Object model,
Component parent,
Map<String,Object> clientSideState)
Update state of the given component and does final preparation for
rendering
|
void |
performComponentInitialization(View view,
Object model,
Component component)
Performs initialization of a component by these steps:
If component id not set, assigns to next available int for view
For
InputField instances, set defaults from the data
dictionary.
Invoke the initialize method on the component. |
void |
performComponentLifecycle(View view,
Object model,
Component component,
String origId)
Performs the complete component lifecycle on the component passed in, in this order:
performComponentInitialization, performComponentApplyModel, and performComponentFinalize.
|
protected void |
performCustomApplyModel(View view,
Component component,
Object model)
Hook for service overrides to perform custom apply model logic on the
component
|
protected void |
performCustomFinalize(View view,
Component component,
Object model,
Component parent)
Hook for service overrides to perform custom component finalization
|
protected void |
performCustomInitialization(View view,
Component component)
Hook for service overrides to perform custom initialization on the
component
|
protected boolean |
performDeleteLineValidation(View view,
CollectionGroup collectionGroup,
Object deleteLine)
Performs validation on the collection line before it is removed from the
corresponding collection
|
void |
performFinalize(View view,
Object model)
The last phase before the view is rendered.
|
void |
performInitialization(View view,
Object model)
Performs the Initialization phase for the
View . |
protected void |
populateDefaultValueForField(View view,
Object object,
DataField dataField,
String bindingPath)
Applies the default value configured for the given field (if any) to the
line given object property that is determined by the given binding path
|
void |
populateViewFromRequestParameters(View view,
Map<String,String> parameters)
Uses reflection to find all fields defined on the
View instance that have
the RequestParameter annotation (which indicates the field may be populated by the request). |
protected void |
processAfterAddLine(View view,
CollectionGroup collectionGroup,
Object model,
Object addLine)
Hook for service overrides to process the new collection line after it
has been added to the collection
|
protected void |
processAfterDeleteLine(View view,
CollectionGroup collectionGroup,
Object model,
int lineIndex)
Hook for service overrides to process the collection line after it has been deleted
|
protected void |
processAnyRemoteFieldsHolder(View view,
Object model,
Container container)
Iterates through the containers configured items checking for
RemotableFieldsHolder , if found
the holder is invoked to retrieved the remotable fields and translate to attribute fields. |
protected void |
processBeforeAddLine(View view,
CollectionGroup collectionGroup,
Object model,
Object addLine)
Hook for service overrides to process the new collection line before it
is added to the collection
|
void |
processCollectionAddLine(View view,
Object model,
String collectionPath)
Invoked when the add line action is chosen for a collection.
|
void |
processCollectionDeleteLine(View view,
Object model,
String collectionPath,
int lineIndex)
Invoked when the delete line action is chosen for a collection.
|
void |
processMultipleValueLookupResults(View view,
Object model,
String collectionPath,
String lookupResultValues)
Process the results returned from a multi-value lookup populating the lines for the collection given
by the path
|
protected void |
retrieveEditModesAndActionFlags(View view,
UifFormBase model)
Invokes the configured
PresentationController and
Authorizer for the view to get the exported action flags
and edit modes that can be used in conditional logic |
protected void |
runComponentModifiers(View view,
Component component,
Object model,
String runPhase)
Runs any configured
ComponentModifiers for the given
component that match the given run phase and who run condition evaluation
succeeds |
void |
setDataDictionaryService(DataDictionaryService dataDictionaryService) |
void |
setExpressionEvaluatorService(ExpressionEvaluatorService expressionEvaluatorService) |
protected void |
setViewContext(View view,
Object model)
Sets up the view context which will be available to other components
through their context for conditional logic evaluation
|
void |
setViewDictionaryService(ViewDictionaryService viewDictionaryService) |
protected void |
syncClientSideStateForComponent(Component component,
Map<String,Object> clientSideState)
Updates the properties of the given component instance with the value found from the corresponding map of
client state (if found)
|
public ViewHelperServiceImpl()
public void populateViewFromRequestParameters(View view, Map<String,String> parameters)
View
instance that have
the RequestParameter
annotation (which indicates the field may be populated by the request).
For each field found, if there is a corresponding key/value pair in the request parameters,
the value is used to populate the field. In addition, any conditional properties of
PropertyReplacers
configured for the field are cleared so that the request parameter
value does not get overridden by the dictionary conditional logic
populateViewFromRequestParameters
in interface ViewHelperService
ViewHelperService.populateViewFromRequestParameters(org.kuali.rice.krad.uif.view.View,
java.util.Map)
public void performInitialization(View view, Object model)
ViewHelperService
View
. During this
phase each component of the tree is invoked to setup state based on the
configuration and request options.
The initialize phase is only called once per View
lifecycle
Note the View
instance also contains the context Map that
was created based on the parameters sent to the view service
performInitialization
in interface ViewHelperService
view
- - View instance that should be initializedmodel
- - object instance containing the view dataViewHelperService.performInitialization(org.kuali.rice.krad.uif.view.View,
java.lang.Object)
public void performComponentLifecycle(View view, Object model, Component component, String origId)
performComponentLifecycle
in interface ViewHelperService
view
- - view instance the component belongs tomodel
- - object containing the full view datacomponent
- - component instance to perform lifecycle fororigId
- - id of the component within the view, used to pull the current component from the vieworg.kuali.rice.krad.uif.service.ViewHelperService#performComponentLifecycle(
org.kuali.rice.krad.uif.view.View, java.lang.Object, org.kuali.rice.krad.uif.component.Component,
java.lang.String)
,
#performComponentInitialization(org.kuali.rice.krad.uif.view.View, Object,
org.kuali.rice.krad.uif.component.Component)}
,
#performComponentApplyModel(View, Component, Object)}
,
#performComponentFinalize(View, Component, Object, Component, Map)}
public void performComponentInitialization(View view, Object model, Component component)
InputField
instances, set defaults from the data
dictionary.ComponentModifier
instances for
the component.Note the order various initialize points are called, this can sometimes be an important factor to consider when initializing a component
performComponentInitialization
in interface ViewHelperService
view
- - view instance the component belongs tomodel
- - object instance containing the view datacomponent
- - component instance that should be initializedViewHelperService.performComponentInitialization(org.kuali.rice.krad.uif.view.View,
java.lang.Object, org.kuali.rice.krad.uif.component.Component)
protected void processAnyRemoteFieldsHolder(View view, Object model, Container container)
RemotableFieldsHolder
, if found
the holder is invoked to retrieved the remotable fields and translate to attribute fields. The translated list
is then inserted into the container item list at the position of the holderview
- - view instance containing the containermodel
- - object instance containing the view datacontainer
- - container instance to check for any remotable fields holderprotected void initializeDataFieldFromDataDictionary(View view, DataField field)
InputField
(if blank) to the
corresponding attribute entry in the data dictionaryview
- - view instance containing the fieldfield
- - data field instance to initializeprotected AttributeDefinition findNestedDictionaryAttribute(View view, DataField field, String parentPath, String propertyPath)
e.g. suppose parentPath is 'document' and propertyPath is 'account.subAccount.name', first the property type for document will be retrieved using the view metadata and used as the dictionary entry, with the propertyPath as the dictionary attribute, if an attribute definition exists it will be returned. Else, the first part of the property path is added to the parent, making the parentPath 'document.account' and the propertyPath 'subAccount.name', the method is then called again to perform the process with those parameters. The recursion continues until an attribute field is found, or the propertyPath is no longer nested
view
- - view instance containing the fieldfield
- - field we are attempting to find a supporting attribute
definition forparentPath
- - parent path to use for getting the dictionary entrypropertyPath
- - path of the property relative to the parent, to use as
dictionary attribute and to drill down onpublic void performApplyModel(View view, Object model)
ViewHelperService
Part of the view lifecycle that applies the model data to the view. Should be called after the model has been populated before the view is rendered. The main things that occur during this phase are:
The update phase can be called multiple times for the view's lifecycle (typically only once per request)
performApplyModel
in interface ViewHelperService
view
- - View instance that the model should be applied tomodel
- - Top level object containing the data (could be the form or a
top level business object, dto)ViewHelperService.performApplyModel(org.kuali.rice.krad.uif.view.View,
java.lang.Object)
protected void retrieveEditModesAndActionFlags(View view, UifFormBase model)
PresentationController
and
Authorizer for the view to get the exported action flags
and edit modes that can be used in conditional logicview
- - view instance that is being built and presentation/authorizer pulled formodel
- - Object that contains the model dataprotected void setViewContext(View view, Object model)
view
- - view instance to set context formodel
- - object containing the view dataprotected Map<String,Object> getPreModelContext(View view)
view
- - view instance for contextprotected void performComponentApplyModel(View view, Component component, Object model)
The component is invoked to to apply the model data. Here the component can generate any additional fields needed or alter the configured fields. After the component is invoked a hook for custom helper service processing is invoked. Finally the method is recursively called for all the component children
view
- - view instance the component belongs tocomponent
- - the component instance the model should be applied tomodel
- - top level object containing the dataprotected void applyAuthorizationAndPresentationLogic(View view, Component component, ViewModel model)
ViewAuthorizer
and ViewPresentationController
to set state of
the component
The following authorization is done here: Fields: edit, view, required, mask, and partial mask Groups: edit and view Actions: take action
Note additional checks are also done for fields that are part of a collection group. This authorization is
found in CollectionGroupBuilder
view
- - view instance the component belongs to and from which the authorizer and presentation controller
will be pulledcomponent
- - component instance to authorizemodel
- - model object containing the data for the viewprotected void runComponentModifiers(View view, Component component, Object model, String runPhase)
ComponentModifiers
for the given
component that match the given run phase and who run condition evaluation
succeeds
If called during the initialize phase, the performInitialization method will be invoked on
the ComponentModifier
before running
view
- - view instance for contextcomponent
- - component instance whose modifiers should be runmodel
- - model object for contextrunPhase
- - current phase to match onprotected Map<String,Object> getCommonContext(View view, Component component)
view
- - view instance for componentcomponent
- - component instance to push context topublic void performFinalize(View view, Object model)
ViewHelperService
The finalize phase runs after the apply model phase and can be called multiple times for the view's lifecylce (however typically only once per request)
performFinalize
in interface ViewHelperService
view
- - view instance that should be finalized for renderingmodel
- - top level object containing the dataViewHelperService.performFinalize(org.kuali.rice.krad.uif.view.View,
java.lang.Object)
protected String buildClientSideStateScript(View view, Map<String,Object> clientSideState, boolean updateOnly)
Here client side state is initialized along with configuration variables that need exposed to script
view
- - view instance that is being builtclientSideState
- - map of key/value pairs that should be exposed as client side stateupdateOnly
- - boolean that indicates whether we are just updating a component (true), or the full viewprotected void performComponentFinalize(View view, Component component, Object model, Component parent, Map<String,Object> clientSideState)
view
- - view instance the component belongs tocomponent
- - the component instance that should be updatedmodel
- - top level object containing the dataparent
- - Parent component for the component being finalizedclientSideState
- - map to add client state toprotected void addClientSideStateForComponent(Component component, Map<String,Object> clientSideState)
ClientSideState
and adds the corresponding property name/value pair to the client side state
map
Note if the component is the View
component
- - component instance to get client state forclientSideState
- - map to add client side variable name/values toprotected void syncClientSideStateForComponent(Component component, Map<String,Object> clientSideState)
component
- - component instance to updateclientSideState
- - map of state to sync withprotected void invokeMethodFinalizer(View view, Component component, Object model)
view
- - view instance that contains the componentcomponent
- - component to run finalize method formodel
- - top level object containing the datapublic void processCollectionAddLine(View view, Object model, String collectionPath)
ViewHelperService
MessageMap
processCollectionAddLine
in interface ViewHelperService
view
- - view instance that is being presented (the action was taken
on)model
- - Top level object containing the view data including the
collection and new linecollectionPath
- - full path to the collection on the modelViewHelperService.processCollectionAddLine(org.kuali.rice.krad.uif.view.View,
java.lang.Object, java.lang.String)
protected boolean performAddLineValidation(View view, CollectionGroup collectionGroup, Object model, Object addLine)
view
- - view instance that the action was taken oncollectionGroup
- - collection group component for the collectionaddLine
- - new line instance to validatemodel
- - object instance that contain's the views datapublic void processCollectionDeleteLine(View view, Object model, String collectionPath, int lineIndex)
ViewHelperService
MessageMap
processCollectionDeleteLine
in interface ViewHelperService
view
- - view instance that is being presented (the action was taken
on)model
- - Top level object containing the view data including the
collectioncollectionPath
- - full path to the collection on the modellineIndex
- - index of the collection line that was selected for removalViewHelperService.processCollectionDeleteLine(org.kuali.rice.krad.uif.view.View,
java.lang.Object, java.lang.String, int)
protected boolean performDeleteLineValidation(View view, CollectionGroup collectionGroup, Object deleteLine)
view
- - view instance that the action was taken oncollectionGroup
- - collection group component for the collectiondeleteLine
- - line that will be removedpublic void processMultipleValueLookupResults(View view, Object model, String collectionPath, String lookupResultValues)
ViewHelperService
processMultipleValueLookupResults
in interface ViewHelperService
view
- - view instance the collection belongs tomodel
- - object containing the view datacollectionPath
- - binding path to the collection to populatedlookupResultValues
- - String containing the selected line valuesprocessMultipleValueLookupResults(org.kuali.rice.krad.uif.view.View, java.lang.Object, java.lang.String, java.lang.String)
public void buildInquiryLink(Object dataObject, String propertyName, Inquiry inquiry)
Inquirable
configured for the given data object
class and delegates to it for building the inquiry URLbuildInquiryLink
in interface ViewHelperService
dataObject
- - parent object for the inquiry propertypropertyName
- - name of the property the inquiry is being built forinquiry
- - instance of the inquiry widget being built for the propertyViewHelperService.buildInquiryLink(java.lang.Object,
java.lang.String, org.kuali.rice.krad.uif.widget.Inquiry)
public void applyDefaultValuesForCollectionLine(View view, Object model, CollectionGroup collectionGroup, Object line)
ViewHelperService
applyDefaultValuesForCollectionLine
in interface ViewHelperService
view
- - view instance the collection line belongs tomodel
- - object containing the full view datacollectionGroup
- - collection group component the line belongs toline
- - line instance to apply default values toViewHelperService.applyDefaultValuesForCollectionLine(org.kuali.rice.krad.uif.view.View,
java.lang.Object, org.kuali.rice.krad.uif.container.CollectionGroup,
java.lang.Object)
protected void applyDefaultValues(View view, Component component, Object model)
view
- - view instance we are applying default values forcomponent
- - component that should be checked for default valuesmodel
- - model object that values should be set onprotected void populateDefaultValueForField(View view, Object object, DataField dataField, String bindingPath)
Checks for a configured default value or default value class for the field. If both are given, the configured static default value will win. In addition, if the default value contains an el expression it is evaluated against the initial context
view
- - view instance the field belongs toobject
- - object that should be populateddataField
- - field to check for configured default valuebindingPath
- - path to the property on the object that should be populatedprotected void addCustomContainerComponents(View view, Object model, Container container)
Subclasses can override this method to check for one or more containers by id and then adding components created in code. This is invoked before the initialize method on the container component, so the full lifecycle will be run on the components returned.
New components instances can be retrieved using ComponentFactory
view
- - view instance the container belongs tomodel
- - object containing the view datacontainer
- - container instance to add components toprotected void performCustomInitialization(View view, Component component)
view
- - view instance containing the componentcomponent
- - component instance to initializeprotected void performCustomApplyModel(View view, Component component, Object model)
view
- - view instance containing the componentcomponent
- - component instance to apply model tomodel
- - Top level object containing the data (could be the form or a
top level business object, dto)protected void performCustomFinalize(View view, Component component, Object model, Component parent)
view
- - view instance containing the componentcomponent
- - component instance to updatemodel
- - Top level object containing the dataparent
- - Parent component for the component being finalizedprotected void processBeforeAddLine(View view, CollectionGroup collectionGroup, Object model, Object addLine)
view
- - view instance that is being presented (the action was taken
on)collectionGroup
- - collection group component for the collection the line will
be added tomodel
- - object instance that contain's the views dataaddLine
- - the new line instance to be processedprotected void processAfterAddLine(View view, CollectionGroup collectionGroup, Object model, Object addLine)
view
- - view instance that is being presented (the action was taken
on)collectionGroup
- - collection group component for the collection the line that
was addedmodel
- - object instance that contain's the views dataaddLine
- - the new line that was addedprotected void processAfterDeleteLine(View view, CollectionGroup collectionGroup, Object model, int lineIndex)
view
- - view instance that is being presented (the action was taken on)collectionGroup
- - collection group component for the collection the line that
was addedmodel
- - object instance that contains the views datalineIndex
- - index of the line that was deletedprotected void logAndThrowRuntime(String message)
protected DataDictionaryService getDataDictionaryService()
public void setDataDictionaryService(DataDictionaryService dataDictionaryService)
protected ExpressionEvaluatorService getExpressionEvaluatorService()
public void setExpressionEvaluatorService(ExpressionEvaluatorService expressionEvaluatorService)
public ViewDictionaryService getViewDictionaryService()
public void setViewDictionaryService(ViewDictionaryService viewDictionaryService)
Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.