1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.lifecycle.model;
17
18 import java.util.List;
19 import java.util.UUID;
20
21 import org.kuali.rice.krad.uif.component.BindingInfo;
22 import org.kuali.rice.krad.uif.component.Component;
23 import org.kuali.rice.krad.uif.component.ComponentSecurity;
24 import org.kuali.rice.krad.uif.component.DataBinding;
25 import org.kuali.rice.krad.uif.component.PropertyReplacer;
26 import org.kuali.rice.krad.uif.container.Container;
27 import org.kuali.rice.krad.uif.layout.LayoutManager;
28 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycleTaskBase;
29 import org.kuali.rice.krad.uif.lifecycle.ApplyModelComponentPhase;
30 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
31 import org.kuali.rice.krad.uif.lifecycle.ViewLifecyclePhase;
32 import org.kuali.rice.krad.uif.modifier.ComponentModifier;
33 import org.kuali.rice.krad.uif.util.LifecycleElement;
34 import org.kuali.rice.krad.uif.view.ExpressionEvaluator;
35 import org.kuali.rice.krad.uif.view.View;
36
37
38
39
40
41
42 public class EvaluateExpressionsTask extends ViewLifecycleTaskBase<Component> {
43
44
45
46
47
48
49 public EvaluateExpressionsTask(ViewLifecyclePhase phase) {
50 super(phase, Component.class);
51 }
52
53
54
55
56
57
58
59
60 public String adjustIdIfNecessary(LifecycleElement element) {
61 ApplyModelComponentPhase phase = (ApplyModelComponentPhase) getElementState();
62 String id = element.getId();
63
64 if (phase.visit(element)) {
65 element.setId(id + '-' + UUID.randomUUID());
66 boolean visitedAfter = phase.visit(element);
67 assert !visitedAfter;
68 }
69
70 return id;
71 }
72
73
74
75
76 @Override
77 protected void performLifecycleTask() {
78 ExpressionEvaluator expressionEvaluator = ViewLifecycle.getExpressionEvaluator();
79 View view = ViewLifecycle.getView();
80 Component component = (Component) getElementState().getElement();
81
82 List<PropertyReplacer> componentPropertyReplacers = component.getPropertyReplacers();
83 if (componentPropertyReplacers != null) {
84 for (PropertyReplacer replacer : componentPropertyReplacers) {
85 expressionEvaluator.evaluateExpressionsOnConfigurable(view, replacer, component.getContext());
86 }
87 }
88
89 List<ComponentModifier> componentModifiers = component.getComponentModifiers();
90 if (componentModifiers != null) {
91 for (ComponentModifier modifier : componentModifiers) {
92 expressionEvaluator.evaluateExpressionsOnConfigurable(view, modifier, component.getContext());
93 }
94 }
95
96 expressionEvaluator.evaluateExpressionsOnConfigurable(view, component, component.getContext());
97
98
99 ComponentSecurity componentSecurity = component.getComponentSecurity();
100 expressionEvaluator.evaluateExpressionsOnConfigurable(view, componentSecurity, component.getContext());
101
102
103 if (component instanceof DataBinding) {
104 BindingInfo bindingInfo = ((DataBinding) component).getBindingInfo();
105 expressionEvaluator.evaluateExpressionsOnConfigurable(view, bindingInfo, component.getContext());
106 }
107
108
109 if (component instanceof Container) {
110 LayoutManager layoutManager = ((Container) component).getLayoutManager();
111
112 if (layoutManager != null) {
113 expressionEvaluator.evaluateExpressionsOnConfigurable(view, layoutManager,
114 layoutManager.getContext());
115
116 adjustIdIfNecessary(layoutManager);
117 }
118 }
119 }
120
121 }