1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.lifecycle.finalize;
17
18 import org.kuali.rice.krad.uif.component.Component;
19 import org.kuali.rice.krad.uif.component.DataBinding;
20 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
21 import org.kuali.rice.krad.uif.lifecycle.ViewLifecyclePhase;
22 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycleTaskBase;
23 import org.kuali.rice.krad.uif.util.LifecycleElement;
24 import org.kuali.rice.krad.uif.view.ViewModel;
25
26
27
28
29
30
31 public class SetReadOnlyOnDataBindingTask extends ViewLifecycleTaskBase<DataBinding> {
32
33
34
35
36
37
38 public SetReadOnlyOnDataBindingTask(ViewLifecyclePhase phase) {
39 super(phase, DataBinding.class);
40 }
41
42
43
44
45 @Override
46 protected void performLifecycleTask() {
47
48 LifecycleElement element = getElementState().getElement();
49 ViewModel viewModel = (ViewModel) ViewLifecycle.getModel();
50 if ((element instanceof DataBinding)
51 && ViewLifecycle.getView().isSupportsRequestOverrideOfReadOnlyFields()
52 && !viewModel.getReadOnlyFieldsList().isEmpty()) {
53 DataBinding dataBinding = (DataBinding) element;
54 String propertyName = dataBinding.getPropertyName();
55 if (viewModel.getReadOnlyFieldsList().contains(propertyName)) {
56 ((Component) dataBinding).setReadOnly(true);
57 }
58 }
59 }
60
61 }