View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.lifecycle;
17  
18  import java.util.Queue;
19  
20  import org.kuali.rice.krad.uif.UifConstants;
21  import org.kuali.rice.krad.uif.component.Component;
22  import org.kuali.rice.krad.uif.container.InitializeContainerFromHelperTask;
23  import org.kuali.rice.krad.uif.container.ProcessRemoteFieldsHolderTask;
24  import org.kuali.rice.krad.uif.field.InitializeDataFieldFromDictionaryTask;
25  import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle.LifecycleEvent;
26  import org.kuali.rice.krad.uif.lifecycle.initialize.AssignIdsTask;
27  import org.kuali.rice.krad.uif.lifecycle.initialize.ComponentDefaultInitializeTask;
28  import org.kuali.rice.krad.uif.lifecycle.initialize.HelperCustomInitializeTask;
29  import org.kuali.rice.krad.uif.lifecycle.initialize.PopulateComponentFromExpressionGraphTask;
30  import org.kuali.rice.krad.uif.lifecycle.initialize.PopulatePathTask;
31  import org.kuali.rice.krad.uif.lifecycle.initialize.PopulateReplacersAndModifiersFromExpressionGraphTask;
32  import org.kuali.rice.krad.uif.util.LifecycleElement;
33  
34  /**
35   * Lifecycle phase processing task for initializing a component.
36   *
37   * <p>
38   * During the initialize phase each component of the tree is invoked to setup state based on the
39   * configuration and request options.
40   * </p>
41   *
42   * <p>
43   * The initialize phase is only called once per <code>View</code> lifecycle
44   * </p>
45   *
46   * <p>
47   * Note the <code>View</code> instance also contains the context Map that was created based on the
48   * parameters sent to the view service
49   * </p>
50   *
51   * @author Kuali Rice Team (rice.collab@kuali.org)
52   */
53  public class InitializeComponentPhase extends ViewLifecyclePhaseBase {
54  
55      /**
56       * {@inheritDoc}
57       *
58       * @return UifConstants.ViewPhases.INITIALIZE
59       */
60      @Override
61      public String getViewPhase() {
62          return UifConstants.ViewPhases.INITIALIZE;
63      }
64  
65      /**
66       * {@inheritDoc}
67       * return UifConstants.ViewStatus.CREATED
68       */
69      @Override
70      public String getStartViewStatus() {
71          return UifConstants.ViewStatus.CREATED;
72      }
73  
74      /**
75       * {@inheritDoc}
76       *
77       * @return UifConstants.ViewStatus.INITIALIZED
78       */
79      @Override
80      public String getEndViewStatus() {
81          return UifConstants.ViewStatus.INITIALIZED;
82      }
83  
84      /**
85       * {@inheritDoc}
86       */
87      @Override
88      public LifecycleEvent getEventToNotify() {
89          return null;
90      }
91  
92      /**
93       * Queues initialization phase tasks.
94       * {@inheritDoc}
95       */
96      @Override
97      protected void initializePendingTasks(Queue<ViewLifecycleTask<?>> tasks) {
98          tasks.offer(LifecycleTaskFactory.getTask(AssignIdsTask.class, this));
99          tasks.offer(LifecycleTaskFactory.getTask(PopulatePathTask.class, this));
100         tasks.offer(LifecycleTaskFactory.getTask(PopulateComponentFromExpressionGraphTask.class, this));
101         tasks.offer(LifecycleTaskFactory.getTask(ComponentDefaultInitializeTask.class, this));
102         tasks.offer(LifecycleTaskFactory.getTask(PopulateReplacersAndModifiersFromExpressionGraphTask.class, this));
103         tasks.offer(LifecycleTaskFactory.getTask(InitializeContainerFromHelperTask.class, this));
104         tasks.offer(LifecycleTaskFactory.getTask(ProcessRemoteFieldsHolderTask.class, this));
105         tasks.offer(LifecycleTaskFactory.getTask(InitializeDataFieldFromDictionaryTask.class, this));
106         getElement().initializePendingTasks(this, tasks);
107         tasks.offer(LifecycleTaskFactory.getTask(RunComponentModifiersTask.class, this));
108         tasks.offer(LifecycleTaskFactory.getTask(HelperCustomInitializeTask.class, this));
109     }
110 
111     /**
112      * {@inheritDoc}
113      */
114     @Override
115     protected ViewLifecyclePhase initializeSuccessor(LifecycleElement nestedElement, String nestedPath,
116             Component parent) {
117         return LifecyclePhaseFactory.initialize(nestedElement, getModel(), nestedPath, getRefreshPaths(), parent, null);
118     }
119 
120 }