1 /**
2 * Copyright 2005-2015 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.modifier;
17
18 import java.io.Serializable;
19 import java.util.List;
20 import java.util.Set;
21
22 import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBean;
23 import org.kuali.rice.krad.uif.component.Component;
24 import org.kuali.rice.krad.uif.component.Ordered;
25 import org.kuali.rice.krad.uif.lifecycle.RunComponentModifiersTask;
26
27 /**
28 * Provides modification functionality for a <code>Component</code>
29 *
30 * <p>
31 * <code>ComponentModifier</code> instances are configured by the component's
32 * dictionary definition. They can be used to provide dynamic initialization
33 * behavior for a certain type of component or all components based on the
34 * getComponentsForLifecycle method. In addition they can do dynamic generation of
35 * new <code>Component</code> instances, or replacement of the components or
36 * their properties.
37 * </p>
38 *
39 * <p>
40 * Modifiers provide for more usability and flexibility of component
41 * configuration. For instance if a <code>Group</code> definition is already
42 * configured that is close to what the developer needs, but they need to make
43 * global changes of the group, then can invoke or create a
44 * <code>ComponentModifier</code> for the group to apply those changes. The
45 * configuration can then inherit the exiting group definition and then specify
46 * the modifier to run with the component's componentModifiers property.
47 * </p>
48 *
49 * @author Kuali Rice Team (rice.collab@kuali.org)
50 */
51 public interface ComponentModifier extends UifDictionaryBean, Serializable, Ordered {
52
53 /**
54 * Should be called to initialize the ComponentModifier
55 *
56 * <p>
57 * This is where component modifiers can set defaults and setup other necessary
58 * state. The initialize method should only be called once per layout
59 * manager lifecycle and is invoked within the initialize phase of the view
60 * lifecylce.
61 * </p>
62 *
63 * <p>
64 * Note if the component modifier holds nested components, they should be initialized
65 * in this method by calling the view helper service
66 * </p>
67 *
68 * @param model - object instance containing the view data
69 * @param component - Component the modifier is configured on
70 * @see RunComponentModifiersTask
71 */
72 public void performInitialization(Object model, Component component);
73
74 /**
75 * Invoked within the configured phase of the component lifecycle. This is
76 * where the <code>ComponentModifier</code> should perform its work against
77 * the given <code>Component</code> instance
78 *
79 * @param model - top level object containing the view data
80 * @param component - the component instance to modify
81 * @see RunComponentModifiersTask
82 */
83 public void performModification(Object model, Component component);
84
85 /**
86 * <code>Set</code> of <code>Component</code> classes that may be sent to
87 * the modifier
88 *
89 * <p>
90 * If an empty or null list is returned, it is assumed the modifier supports
91 * all components. The returned set will be used by the dictionary
92 * validation
93 * </p>
94 *
95 * @return Set component classes
96 */
97 public Set<Class<? extends Component>> getSupportedComponents();
98
99 /**
100 * List of components that are maintained by the modifier as prototypes for creating other component instances
101 *
102 * <p>
103 * Prototypes are held for configuring how a component should be created during the lifecycle. An example of this
104 * are the fields in a collection group that are created for each collection record. They only participate in the
105 * initialize phase.
106 * </p>
107 *
108 * @return List<Component> child component prototypes
109 */
110 public List<Component> getComponentPrototypes();
111
112 /**
113 * Indicates what phase of the component lifecycle the
114 * <code>ComponentModifier</code> should be invoked in (INITIALIZE,
115 * APPLY_MODEL, or FINALIZE)
116 *
117 * @return String view lifecycle phase
118 * @see org.kuali.rice.krad.uif.UifConstants.ViewPhases
119 */
120 public String getRunPhase();
121
122 /**
123 * Conditional expression to evaluate for determining whether the component
124 * modifier should be run. If the expression evaluates to true the modifier
125 * will be executed, otherwise it will not be executed
126 *
127 * @return String el expression that should evaluate to boolean
128 */
129 public String getRunCondition();
130
131 /**
132 * @see org.springframework.core.Ordered#getOrder()
133 */
134 public int getOrder();
135
136 /**
137 * @see org.kuali.rice.krad.uif.component.Ordered#setOrder(int)
138 */
139 public void setOrder(int order);
140
141 }