Class CollectionGroupBuilder

java.lang.Object
org.kuali.rice.krad.uif.container.CollectionGroupBuilder
All Implemented Interfaces:
Serializable

public class CollectionGroupBuilder extends Object implements Serializable
Builds out the Field instances for a collection group with a series of steps that interact with the configured CollectionLayoutManager to assemble the fields as necessary for the layout.
Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
  • Constructor Details

    • CollectionGroupBuilder

      public CollectionGroupBuilder()
  • Method Details

    • build

      public void build(View view, Object model, CollectionGroup collectionGroup)
      Invoked within the lifecycle to carry out the collection build process.

      The corresponding collection is retrieved from the model and iterated over to create the necessary fields. The binding path for fields that implement DataBinding is adjusted to point to the collection line it is apart of. For example, field 'number' of collection 'accounts' for line 1 will be set to 'accounts[0].number', and for line 2 'accounts[1].number'. Finally parameters are set on the line's action fields to indicate what collection and line they apply to.

      Only the lines that are to be rendered (as specified by the displayStart and displayLength properties of the CollectionGroup) will be built.

      Parameters:
      view - View instance the collection belongs to
      model - Top level object containing the data
      collectionGroup - CollectionGroup component for the collection
    • buildLinesForDisplayedRows

      protected void buildLinesForDisplayedRows(List<org.kuali.rice.krad.uif.container.CollectionGroupBuilder.IndexedElement> filteredIndexedElements, View view, Object model, CollectionGroup collectionGroup)
      Build the lines for the collection rows to be rendered.
      Parameters:
      filteredIndexedElements - a filtered and indexed list of the model collection elements
      view - View instance the collection belongs to
      model - Top level object containing the data
      collectionGroup - CollectionGroup component for the collection
    • initializeEditLineDialog

      protected void initializeEditLineDialog(CollectionGroup collectionGroup, int lineIndex, Object currentLine, Object model)
      Helper method to initialize the edit line dialog and add it to the line dialogs for the group.
      Parameters:
      collectionGroup - the collection group to initialize the line dialogs for
      lineIndex - the current line index
      currentLine - the data object bound to the current line
      model - the view's data
    • setupEditLineDialog

      protected void setupEditLineDialog(DialogGroup editLineDialog, CollectionGroup group, int lineIndex, String lineSuffix, Object currentLine)
      Helper method to create and setup the edit line dialog for the indexed line.
      Parameters:
      editLineDialog - the dialog to setup for editing the line
      group - the collection group to create line dialogs for
      lineIndex - the current line index
      lineSuffix - the line suffix to use on dialog component id's
      currentLine - the data object bound to the current line
    • performCollectionFiltering

      protected List<Integer> performCollectionFiltering(View view, Object model, CollectionGroup collectionGroup, Collection<?> collection)
      Performs any filtering necessary on the collection before building the collection fields.

      If showInactive is set to false and the collection line type implements Inactivatable, invokes the active collection filter. Then any CollectionFilter instances configured for the collection group are invoked to filter the collection. Collections lines must pass all filters in order to be displayed

      Parameters:
      view - view instance that contains the collection
      model - object containing the views data
      collectionGroup - collection group component instance that will display the collection
      collection - collection instance that will be filtered
    • buildAddLine

      protected void buildAddLine(View view, Object model, CollectionGroup collectionGroup)
      Builds the fields for holding the collection add line and if necessary makes call to setup the new line instance.
      Parameters:
      view - view instance the collection belongs to
      model - Object containing the view data, should extend UifFormBase if using framework managed new lines
      collectionGroup - collection group the layout manager applies to
    • initializeLineActions

      protected List<? extends Component> initializeLineActions(List<? extends Component> lineActions, View view, CollectionGroup collectionGroup, Object collectionLine, int lineIndex)
      Creates new Action instances for the line.

      Adds context to the action fields for the given line so that the line the action was performed on can be determined when that action is selected

      Parameters:
      lineActions - the actions to copy
      view - view instance the collection belongs to
      collectionGroup - collection group component for the collection
      collectionLine - object instance for the current line
      lineIndex - index of the line the actions should apply to
    • setupEditLineActionForDialog

      protected Action setupEditLineActionForDialog(CollectionGroup collectionGroup, String lineSuffix, int lineIndex, int actionIndex)
      Helper method to setup the edit line action to show the dialog
      Parameters:
      collectionGroup - the collection group the line belongs to
      lineSuffix - the line index of the current line
      lineIndex - the current line index
      actionIndex - the action index used in the id
      Returns:
      the line action for edit line in dialog
    • initializeActions

      public void initializeActions(List<Action> actions, CollectionGroup collectionGroup, int lineIndex)
      Updates the action parameters, jump to, refresh id, and validation configuration for the list of actions associated with the given collection group and line index.
      Parameters:
      actions - list of action components to update
      collectionGroup - collection group instance the actions belong to
      lineIndex - index of the line the actions are associate with
    • getAddLineActionComponents

      protected List<? extends Component> getAddLineActionComponents(View view, Object model, CollectionGroup collectionGroup)
      Creates new Component instances for the add line

      Adds context to the action fields for the add line so that the collection the action was performed on can be determined

      Parameters:
      view - view instance the collection belongs to
      model - top level object containing the data
      collectionGroup - collection group component for the collection
    • initializeNewCollectionLine

      public void initializeNewCollectionLine(View view, Object model, CollectionGroup collectionGroup, boolean clearExistingLine)
      Initializes a new instance of the collection data object class for the add line.

      If the add line property was not specified for the collection group the new lines will be added to the generic map on the UifFormBase, else it will be added to the property given by the addLineBindingInfo

      New line will only be created if the current line property is null or clearExistingLine is true. In the case of a new line default values are also applied

    • refreshEditLineDialogContents

      public boolean refreshEditLineDialogContents(DialogGroup dialogGroup, Object model, CollectionGroup collectionGroup, int lineIndex)
      Helper method that checks if this is a refresh lifecycle and if the component to be refreshed is the dialog group, and if the action parameters bind to the same object as the collection's current line, and if they are then it returns true.
      Parameters:
      dialogGroup - the dialog group to check for
      model - the form data
      collectionGroup - the collection group the line belongs to
      lineIndex - the current line index
      Returns:
    • getCollectionGroupLineBuilder

      public CollectionGroupLineBuilder getCollectionGroupLineBuilder(LineBuilderContext lineBuilderContext)
      Returns an instance of CollectionGroupLineBuilder for building the line.
      Parameters:
      lineBuilderContext - context of line for initializing line builder
      Returns:
      CollectionGroupLineBuilder instance