1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.component;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
22 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
23 import org.kuali.rice.krad.datadictionary.validator.Validator;
24 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
25 import org.kuali.rice.krad.uif.CssConstants;
26 import org.kuali.rice.krad.uif.control.ControlBase;
27 import org.kuali.rice.krad.uif.modifier.ComponentModifier;
28 import org.kuali.rice.krad.uif.service.ExpressionEvaluatorService;
29 import org.kuali.rice.krad.uif.util.ExpressionUtils;
30 import org.kuali.rice.krad.uif.util.ScriptUtils;
31 import org.kuali.rice.krad.uif.view.View;
32 import org.kuali.rice.krad.uif.widget.Tooltip;
33 import org.kuali.rice.krad.util.ObjectUtils;
34
35 import java.util.ArrayList;
36 import java.util.HashMap;
37 import java.util.List;
38 import java.util.Map;
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 @BeanTag(name = "componentBase-bean", parent = "Uif-ComponentBase")
54 public abstract class ComponentBase extends UifDictionaryBeanBase implements Component {
55 private static final long serialVersionUID = -4449335748129894350L;
56
57 private String id;
58 private String baseId;
59 private String template;
60 private String templateName;
61
62 private String title;
63
64 private boolean render;
65
66 @KeepExpression
67 private String progressiveRender;
68 private boolean progressiveRenderViaAJAX;
69 private boolean progressiveRenderAndRefresh;
70 private List<String> progressiveDisclosureControlNames;
71 private String progressiveDisclosureConditionJs;
72
73 @KeepExpression
74 private String conditionalRefresh;
75 private String conditionalRefreshConditionJs;
76 private List<String> conditionalRefreshControlNames;
77
78 private List<String> refreshWhenChangedPropertyNames;
79 private List<String> additionalComponentsToRefresh;
80 private String additionalComponentsToRefreshJs;
81 private boolean refreshedByAction;
82 private boolean disclosedByAction;
83
84 private int refreshTimer;
85
86 private boolean resetDataOnRefresh;
87 private String methodToCallOnRefresh;
88
89 private boolean hidden;
90 private boolean readOnly;
91 private Boolean required;
92
93 private String align;
94 private String valign;
95 private String width;
96
97
98 private int colSpan;
99 private int rowSpan;
100 private List<String> cellCssClasses;
101 private String cellStyle;
102 private String cellWidth;
103
104 private String style;
105 private List<String> cssClasses;
106
107 private Tooltip toolTip;
108
109 private int order;
110
111 private boolean skipInTabOrder;
112
113 private String finalizeMethodToCall;
114 private List<Object> finalizeMethodAdditionalArguments;
115 private MethodInvokerConfig finalizeMethodInvoker;
116
117 private boolean selfRendered;
118 private String renderedHtmlOutput;
119
120 private boolean disableSessionPersistence;
121 private boolean forceSessionPersistence;
122
123 private ComponentSecurity componentSecurity;
124
125 private String onLoadScript;
126 private String onUnloadScript;
127 private String onCloseScript;
128 private String onBlurScript;
129 private String onChangeScript;
130 private String onClickScript;
131 private String onDblClickScript;
132 private String onFocusScript;
133 private String onSubmitScript;
134 private String onKeyPressScript;
135 private String onKeyUpScript;
136 private String onKeyDownScript;
137 private String onMouseOverScript;
138 private String onMouseOutScript;
139 private String onMouseUpScript;
140 private String onMouseDownScript;
141 private String onMouseMoveScript;
142 private String onDocumentReadyScript;
143
144 private List<ComponentModifier> componentModifiers;
145
146 private Map<String, String> templateOptions;
147 private String templateOptionsJSString;
148
149 @ReferenceCopy(newCollectionInstance = true)
150 private transient Map<String, Object> context;
151
152 private List<PropertyReplacer> propertyReplacers;
153
154 private Map<String, String> dataAttributes;
155
156 public ComponentBase() {
157 super();
158
159 order = 0;
160 colSpan = 1;
161 rowSpan = 1;
162
163 render = true;
164 selfRendered = false;
165 progressiveRenderViaAJAX = false;
166 progressiveRenderAndRefresh = false;
167 refreshedByAction = false;
168 resetDataOnRefresh = false;
169 disableSessionPersistence = false;
170 forceSessionPersistence = false;
171
172 componentSecurity = ObjectUtils.newInstance(getComponentSecurityClass());
173
174 refreshWhenChangedPropertyNames = new ArrayList<String>();
175 additionalComponentsToRefresh = new ArrayList<String>();
176 finalizeMethodAdditionalArguments = new ArrayList<Object>();
177 cellCssClasses = new ArrayList<String>();
178 cssClasses = new ArrayList<String>();
179 componentModifiers = new ArrayList<ComponentModifier>();
180 templateOptions = new HashMap<String, String>();
181 context = new HashMap<String, Object>();
182 propertyReplacers = new ArrayList<PropertyReplacer>();
183 dataAttributes = new HashMap<String, String>();
184 }
185
186
187
188
189
190
191
192
193
194
195 public void performInitialization(View view, Object model) {
196
197 }
198
199
200
201
202
203
204
205
206
207
208
209
210 public void performApplyModel(View view, Object model, Component parent) {
211 if (this.render && StringUtils.isNotEmpty(progressiveRender)) {
212
213 ExpressionEvaluatorService expressionEvaluatorService =
214 KRADServiceLocatorWeb.getExpressionEvaluatorService();
215 String adjustedProgressiveRender = expressionEvaluatorService.replaceBindingPrefixes(view, this,
216 progressiveRender);
217 Boolean progRenderEval = (Boolean) expressionEvaluatorService.evaluateExpression(model, context,
218 adjustedProgressiveRender);
219
220 this.setRender(progRenderEval);
221 }
222 }
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 public void performFinalize(View view, Object model, Component parent) {
238 if (StringUtils.isNotEmpty(progressiveRender)) {
239 progressiveRender = KRADServiceLocatorWeb.getExpressionEvaluatorService().replaceBindingPrefixes(view, this,
240 progressiveRender);
241 progressiveDisclosureControlNames = new ArrayList<String>();
242 progressiveDisclosureConditionJs = ExpressionUtils.parseExpression(progressiveRender,
243 progressiveDisclosureControlNames);
244 }
245
246 if (StringUtils.isNotEmpty(conditionalRefresh)) {
247 conditionalRefresh = KRADServiceLocatorWeb.getExpressionEvaluatorService().replaceBindingPrefixes(view,
248 this, conditionalRefresh);
249 conditionalRefreshControlNames = new ArrayList<String>();
250 conditionalRefreshConditionJs = ExpressionUtils.parseExpression(conditionalRefresh,
251 conditionalRefreshControlNames);
252 }
253
254 List<String> adjustedRefreshPropertyNames = new ArrayList<String>();
255 for (String refreshPropertyName : refreshWhenChangedPropertyNames) {
256 adjustedRefreshPropertyNames.add(
257 KRADServiceLocatorWeb.getExpressionEvaluatorService().replaceBindingPrefixes(view, this,
258 refreshPropertyName));
259 }
260 refreshWhenChangedPropertyNames = adjustedRefreshPropertyNames;
261
262
263 if (StringUtils.isNotBlank(getAlign()) && !StringUtils.contains(getStyle(), CssConstants.TEXT_ALIGN)) {
264 appendToStyle(CssConstants.TEXT_ALIGN + getAlign() + ";");
265 }
266
267 if (StringUtils.isNotBlank(getValign()) && !StringUtils.contains(getStyle(), CssConstants.VERTICAL_ALIGN)) {
268 appendToStyle(CssConstants.VERTICAL_ALIGN + getValign() + ";");
269 }
270
271 if (StringUtils.isNotBlank(getWidth()) && !StringUtils.contains(getStyle(), CssConstants.WIDTH)) {
272 appendToStyle(CssConstants.WIDTH + getWidth() + ";");
273 }
274
275
276
277 for (Component component : getComponentsForLifecycle()) {
278 if (component != null && component instanceof ComponentBase && skipInTabOrder) {
279 ((ComponentBase) component).setSkipInTabOrder(skipInTabOrder);
280 if (component instanceof ControlBase) {
281 ((ControlBase) component).setTabIndex(-1);
282 }
283 }
284 }
285
286
287
288 boolean hide = false;
289 if (!this.render && !this.progressiveRenderViaAJAX && !this.progressiveRenderAndRefresh && StringUtils
290 .isNotBlank(progressiveRender)) {
291 hide = true;
292 } else if (this.isHidden()) {
293 hide = true;
294 }
295
296 if (hide) {
297 if (StringUtils.isNotBlank(this.getStyle())) {
298 if (this.getStyle().endsWith(";")) {
299 this.setStyle(this.getStyle() + " display: none;");
300 } else {
301 this.setStyle(this.getStyle() + "; display: none;");
302 }
303 } else {
304 this.setStyle("display: none;");
305 }
306 }
307 }
308
309
310
311
312 public List<Component> getComponentsForLifecycle() {
313 List<Component> components = new ArrayList<Component>();
314
315 components.add(toolTip);
316
317 return components;
318 }
319
320
321
322
323 public List<Component> getComponentPrototypes() {
324 List<Component> components = new ArrayList<Component>();
325
326 for (ComponentModifier modifier : componentModifiers) {
327 components.addAll(modifier.getComponentPrototypes());
328 }
329
330 components.addAll(getPropertyReplacerComponents());
331
332 return components;
333 }
334
335
336
337
338
339
340 public List<Component> getPropertyReplacerComponents() {
341 List<Component> components = new ArrayList<Component>();
342 for (Object replacer : propertyReplacers) {
343 components.addAll(((PropertyReplacer) replacer).getNestedComponents());
344 }
345
346 return components;
347 }
348
349
350
351
352 @BeanTagAttribute(name = "id")
353 public String getId() {
354 return this.id;
355 }
356
357
358
359
360 public void setId(String id) {
361 this.id = id;
362 }
363
364
365
366
367 public String getBaseId() {
368 return this.baseId;
369 }
370
371
372
373
374 public void setBaseId(String baseId) {
375 this.baseId = baseId;
376 }
377
378
379
380
381 @BeanTagAttribute(name = "template")
382 public String getTemplate() {
383 return this.template;
384 }
385
386
387
388
389 public void setTemplate(String template) {
390 this.template = template;
391 }
392
393 @BeanTagAttribute(name = "templateName")
394 public String getTemplateName() {
395 return templateName;
396 }
397
398 public void setTemplateName(String templateName) {
399 this.templateName = templateName;
400 }
401
402
403
404
405 @BeanTagAttribute(name = "title")
406 public String getTitle() {
407 return this.title;
408 }
409
410
411
412
413 public void setTitle(String title) {
414 this.title = title;
415 }
416
417
418
419
420 @BeanTagAttribute(name = "hidden")
421 public boolean isHidden() {
422 return this.hidden;
423 }
424
425
426
427
428 public void setHidden(boolean hidden) {
429 this.hidden = hidden;
430 }
431
432
433
434
435 @BeanTagAttribute(name = "readOnly")
436 public boolean isReadOnly() {
437 return this.readOnly;
438 }
439
440
441
442
443 public void setReadOnly(boolean readOnly) {
444 this.readOnly = readOnly;
445 }
446
447
448
449
450 @BeanTagAttribute(name = "required")
451 public Boolean getRequired() {
452 return this.required;
453 }
454
455
456
457
458 public void setRequired(Boolean required) {
459 this.required = required;
460 }
461
462
463
464
465 @BeanTagAttribute(name = "render")
466 public boolean isRender() {
467 return this.render;
468 }
469
470
471
472
473 public void setRender(boolean render) {
474 this.render = render;
475 }
476
477
478
479
480 @BeanTagAttribute(name = "ColSpan")
481 public int getColSpan() {
482 return this.colSpan;
483 }
484
485
486
487
488 public void setColSpan(int colSpan) {
489 this.colSpan = colSpan;
490 }
491
492
493
494
495 @BeanTagAttribute(name = "rowSpan")
496 public int getRowSpan() {
497 return this.rowSpan;
498 }
499
500
501
502
503 public void setRowSpan(int rowSpan) {
504 this.rowSpan = rowSpan;
505 }
506
507
508
509
510 public List<String> getCellCssClasses() {
511 return cellCssClasses;
512 }
513
514
515
516
517 public void setCellCssClasses(List<String> cellCssClasses) {
518 this.cellCssClasses = cellCssClasses;
519 }
520
521
522
523
524 public void addCellCssClass(String cssClass) {
525 if (this.cellCssClasses == null){
526 this.cellCssClasses = new ArrayList<String>();
527 }
528
529 if(cssClass != null){
530 this.cellCssClasses.add(cssClass);
531 }
532 }
533
534
535
536
537
538
539
540 public String getCellStyleClassesAsString() {
541 if (cellCssClasses != null) {
542 return StringUtils.join(cellCssClasses, " ");
543 }
544
545 return "";
546 }
547
548
549
550
551 public String getCellStyle() {
552 return cellStyle;
553 }
554
555
556
557
558 public void setCellStyle(String cellStyle) {
559 this.cellStyle = cellStyle;
560 }
561
562
563
564
565 public String getCellWidth() {
566 return cellWidth;
567 }
568
569
570
571
572 public void setCellWidth(String cellWidth) {
573 this.cellWidth = cellWidth;
574 }
575
576
577
578
579 @BeanTagAttribute(name = "align")
580 public String getAlign() {
581 return this.align;
582 }
583
584
585
586
587 public void setAlign(String align) {
588 this.align = align;
589 }
590
591
592
593
594 @BeanTagAttribute(name = "valign")
595 public String getValign() {
596 return this.valign;
597 }
598
599
600
601
602 public void setValign(String valign) {
603 this.valign = valign;
604 }
605
606
607
608
609 @BeanTagAttribute(name = "width")
610 public String getWidth() {
611 return this.width;
612 }
613
614
615
616
617 public void setWidth(String width) {
618 this.width = width;
619 }
620
621
622
623
624 @BeanTagAttribute(name = "style")
625 public String getStyle() {
626 return this.style;
627 }
628
629
630
631
632 public void setStyle(String style) {
633 this.style = style;
634 }
635
636
637
638
639 @BeanTagAttribute(name = "cssClasses", type = BeanTagAttribute.AttributeType.LISTVALUE)
640 public List<String> getCssClasses() {
641 return this.cssClasses;
642 }
643
644
645
646
647 public void setCssClasses(List<String> cssClasses) {
648 this.cssClasses = cssClasses;
649 }
650
651
652
653
654
655
656
657 public String getStyleClassesAsString() {
658 if (cssClasses != null) {
659 return StringUtils.join(cssClasses, " ");
660 }
661
662 return "";
663 }
664
665
666
667
668 public void addStyleClass(String styleClass) {
669 if (!cssClasses.contains(styleClass)) {
670 cssClasses.add(styleClass);
671 }
672 }
673
674
675
676
677 public void appendToStyle(String styleRules) {
678 if (style == null) {
679 style = "";
680 }
681 style = style + styleRules;
682 }
683
684
685
686
687 @BeanTagAttribute(name = "finalizeMethodToCall")
688 public String getFinalizeMethodToCall() {
689 return this.finalizeMethodToCall;
690 }
691
692
693
694
695
696
697 public void setFinalizeMethodToCall(String finalizeMethodToCall) {
698 this.finalizeMethodToCall = finalizeMethodToCall;
699 }
700
701
702
703
704 @BeanTagAttribute(name = "finalizeMethodAdditionalArguments", type = BeanTagAttribute.AttributeType.LISTBEAN)
705 public List<Object> getFinalizeMethodAdditionalArguments() {
706 return finalizeMethodAdditionalArguments;
707 }
708
709
710
711
712
713
714 public void setFinalizeMethodAdditionalArguments(List<Object> finalizeMethodAdditionalArguments) {
715 this.finalizeMethodAdditionalArguments = finalizeMethodAdditionalArguments;
716 }
717
718
719
720
721 @BeanTagAttribute(name = "finalizeMethodInvoker", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
722 public MethodInvokerConfig getFinalizeMethodInvoker() {
723 return this.finalizeMethodInvoker;
724 }
725
726
727
728
729
730
731 public void setFinalizeMethodInvoker(MethodInvokerConfig finalizeMethodInvoker) {
732 this.finalizeMethodInvoker = finalizeMethodInvoker;
733 }
734
735
736
737
738 @BeanTagAttribute(name = "selfRendered")
739 public boolean isSelfRendered() {
740 return this.selfRendered;
741 }
742
743
744
745
746 public void setSelfRendered(boolean selfRendered) {
747 this.selfRendered = selfRendered;
748 }
749
750
751
752
753 @BeanTagAttribute(name = "renderedHtmlOutput")
754 public String getRenderedHtmlOutput() {
755 return this.renderedHtmlOutput;
756 }
757
758
759
760
761 public void setRenderedHtmlOutput(String renderedHtmlOutput) {
762 this.renderedHtmlOutput = renderedHtmlOutput;
763 }
764
765
766
767
768 @BeanTagAttribute(name = "disableSessionPersistence")
769 public boolean isDisableSessionPersistence() {
770 return disableSessionPersistence;
771 }
772
773
774
775
776 public void setDisableSessionPersistence(boolean disableSessionPersistence) {
777 this.disableSessionPersistence = disableSessionPersistence;
778 }
779
780
781
782
783 @BeanTagAttribute(name = "forceSessionPersistence")
784 public boolean isForceSessionPersistence() {
785 return forceSessionPersistence;
786 }
787
788
789
790
791 public void setForceSessionPersistence(boolean forceSessionPersistence) {
792 this.forceSessionPersistence = forceSessionPersistence;
793 }
794
795
796
797
798 @BeanTagAttribute(name = "componentSecurity", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
799 public ComponentSecurity getComponentSecurity() {
800 return componentSecurity;
801 }
802
803
804
805
806 public void setComponentSecurity(ComponentSecurity componentSecurity) {
807 this.componentSecurity = componentSecurity;
808 }
809
810
811
812
813
814
815 protected Class<? extends ComponentSecurity> getComponentSecurityClass() {
816 return ComponentSecurity.class;
817 }
818
819
820
821
822 @BeanTagAttribute(name = "componentModifiers", type = BeanTagAttribute.AttributeType.LISTBEAN)
823 public List<ComponentModifier> getComponentModifiers() {
824 return this.componentModifiers;
825 }
826
827
828
829
830 public void setComponentModifiers(List<ComponentModifier> componentModifiers) {
831 this.componentModifiers = componentModifiers;
832 }
833
834
835
836
837 @BeanTagAttribute(name = "context", type = BeanTagAttribute.AttributeType.MAPBEAN)
838 public Map<String, Object> getContext() {
839 return this.context;
840 }
841
842
843
844
845 public void setContext(Map<String, Object> context) {
846 this.context = context;
847 }
848
849
850
851
852
853 public void pushObjectToContext(String objectName, Object object) {
854 if (this.context == null) {
855 this.context = new HashMap<String, Object>();
856 }
857 pushToPropertyReplacerContext(objectName, object);
858 this.context.put(objectName, object);
859 }
860
861
862
863
864
865 protected void pushToPropertyReplacerContext(String objectName, Object object) {
866 for (Component replacerComponent : getPropertyReplacerComponents()) {
867 replacerComponent.pushObjectToContext(objectName, object);
868 }
869 }
870
871
872
873
874 public void pushAllToContext(Map<String, Object> objects) {
875 if (objects != null) {
876 for (Map.Entry<String, Object> objectEntry : objects.entrySet()) {
877 pushObjectToContext(objectEntry.getKey(), objectEntry.getValue());
878 }
879 }
880 }
881
882
883
884
885 @BeanTagAttribute(name = "propertyReplacers", type = BeanTagAttribute.AttributeType.LISTBEAN)
886 public List<PropertyReplacer> getPropertyReplacers() {
887 return this.propertyReplacers;
888 }
889
890
891
892
893 public void setPropertyReplacers(List<PropertyReplacer> propertyReplacers) {
894 this.propertyReplacers = propertyReplacers;
895 }
896
897
898
899
900 @BeanTagAttribute(name = "order")
901 public int getOrder() {
902 return this.order;
903 }
904
905
906
907
908
909
910 public void setOrder(int order) {
911 this.order = order;
912 }
913
914
915
916
917 @BeanTagAttribute(name = "toolTip", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
918 public Tooltip getToolTip() {
919 return toolTip;
920 }
921
922
923
924
925 public void setToolTip(Tooltip toolTip) {
926 this.toolTip = toolTip;
927 }
928
929
930
931
932 @BeanTagAttribute(name = "onLoadScript")
933 public String getOnLoadScript() {
934 return onLoadScript;
935 }
936
937
938
939
940
941
942 public void setOnLoadScript(String onLoadScript) {
943 this.onLoadScript = onLoadScript;
944 }
945
946
947
948
949 @BeanTagAttribute(name = "onDocumentReadyScript")
950 public String getOnDocumentReadyScript() {
951 String onDocScript = this.onDocumentReadyScript;
952
953
954 if (refreshTimer > 0) {
955 onDocScript = (null == onDocScript) ? "" : onDocScript;
956 onDocScript = "refreshComponentUsingTimer('"
957 + this.id
958 + "','"
959 + this.methodToCallOnRefresh
960 + "',"
961 + refreshTimer
962 + ");"
963 + onDocScript;
964 }
965 return onDocScript;
966 }
967
968
969
970
971
972
973 public void setOnDocumentReadyScript(String onDocumentReadyScript) {
974 this.onDocumentReadyScript = onDocumentReadyScript;
975 }
976
977
978
979
980 @BeanTagAttribute(name = "onUnloadScript")
981 public String getOnUnloadScript() {
982 return onUnloadScript;
983 }
984
985
986
987
988
989
990 public void setOnUnloadScript(String onUnloadScript) {
991 this.onUnloadScript = onUnloadScript;
992 }
993
994
995
996
997 @BeanTagAttribute(name = "onCloseScript")
998 public String getOnCloseScript() {
999 return onCloseScript;
1000 }
1001
1002
1003
1004
1005
1006
1007 public void setOnCloseScript(String onCloseScript) {
1008 this.onCloseScript = onCloseScript;
1009 }
1010
1011
1012
1013
1014 @BeanTagAttribute(name = "onBlurScript")
1015 public String getOnBlurScript() {
1016 return onBlurScript;
1017 }
1018
1019
1020
1021
1022
1023
1024 public void setOnBlurScript(String onBlurScript) {
1025 this.onBlurScript = onBlurScript;
1026 }
1027
1028
1029
1030
1031 @BeanTagAttribute(name = "onChangeScript")
1032 public String getOnChangeScript() {
1033 return onChangeScript;
1034 }
1035
1036
1037
1038
1039
1040
1041 public void setOnChangeScript(String onChangeScript) {
1042 this.onChangeScript = onChangeScript;
1043 }
1044
1045
1046
1047
1048 @BeanTagAttribute(name = "onClickScript")
1049 public String getOnClickScript() {
1050 return onClickScript;
1051 }
1052
1053
1054
1055
1056
1057
1058 public void setOnClickScript(String onClickScript) {
1059 this.onClickScript = onClickScript;
1060 }
1061
1062
1063
1064
1065 @BeanTagAttribute(name = "onDblClickScript")
1066 public String getOnDblClickScript() {
1067 return onDblClickScript;
1068 }
1069
1070
1071
1072
1073
1074
1075 public void setOnDblClickScript(String onDblClickScript) {
1076 this.onDblClickScript = onDblClickScript;
1077 }
1078
1079
1080
1081
1082 @BeanTagAttribute(name = "onFocusScript")
1083 public String getOnFocusScript() {
1084 return onFocusScript;
1085 }
1086
1087
1088
1089
1090
1091
1092 public void setOnFocusScript(String onFocusScript) {
1093 this.onFocusScript = onFocusScript;
1094 }
1095
1096
1097
1098
1099 @BeanTagAttribute(name = "onSubmitScript")
1100 public String getOnSubmitScript() {
1101 return onSubmitScript;
1102 }
1103
1104
1105
1106
1107
1108
1109 public void setOnSubmitScript(String onSubmitScript) {
1110 this.onSubmitScript = onSubmitScript;
1111 }
1112
1113
1114
1115
1116 @BeanTagAttribute(name = "onKeyPressScript")
1117 public String getOnKeyPressScript() {
1118 return onKeyPressScript;
1119 }
1120
1121
1122
1123
1124
1125
1126 public void setOnKeyPressScript(String onKeyPressScript) {
1127 this.onKeyPressScript = onKeyPressScript;
1128 }
1129
1130
1131
1132
1133 @BeanTagAttribute(name = "onKeyUpScript")
1134 public String getOnKeyUpScript() {
1135 return onKeyUpScript;
1136 }
1137
1138
1139
1140
1141
1142
1143 public void setOnKeyUpScript(String onKeyUpScript) {
1144 this.onKeyUpScript = onKeyUpScript;
1145 }
1146
1147
1148
1149
1150 @BeanTagAttribute(name = "onKeyDownScript")
1151 public String getOnKeyDownScript() {
1152 return onKeyDownScript;
1153 }
1154
1155
1156
1157
1158
1159
1160 public void setOnKeyDownScript(String onKeyDownScript) {
1161 this.onKeyDownScript = onKeyDownScript;
1162 }
1163
1164
1165
1166
1167 @BeanTagAttribute(name = "onMouseOverScript")
1168 public String getOnMouseOverScript() {
1169 return onMouseOverScript;
1170 }
1171
1172
1173
1174
1175
1176
1177 public void setOnMouseOverScript(String onMouseOverScript) {
1178 this.onMouseOverScript = onMouseOverScript;
1179 }
1180
1181
1182
1183
1184 @BeanTagAttribute(name = "onMouseOutScript")
1185 public String getOnMouseOutScript() {
1186 return onMouseOutScript;
1187 }
1188
1189
1190
1191
1192
1193
1194 public void setOnMouseOutScript(String onMouseOutScript) {
1195 this.onMouseOutScript = onMouseOutScript;
1196 }
1197
1198
1199
1200
1201 @BeanTagAttribute(name = "onMouseUpScript")
1202 public String getOnMouseUpScript() {
1203 return onMouseUpScript;
1204 }
1205
1206
1207
1208
1209
1210
1211 public void setOnMouseUpScript(String onMouseUpScript) {
1212 this.onMouseUpScript = onMouseUpScript;
1213 }
1214
1215
1216
1217
1218 @BeanTagAttribute(name = "onMouseDownScript")
1219 public String getOnMouseDownScript() {
1220 return onMouseDownScript;
1221 }
1222
1223
1224
1225
1226
1227
1228 public void setOnMouseDownScript(String onMouseDownScript) {
1229 this.onMouseDownScript = onMouseDownScript;
1230 }
1231
1232
1233
1234
1235 @BeanTagAttribute(name = "onMouseMoveScript")
1236 public String getOnMouseMoveScript() {
1237 return onMouseMoveScript;
1238 }
1239
1240
1241
1242
1243
1244
1245 public void setOnMouseMoveScript(String onMouseMoveScript) {
1246 this.onMouseMoveScript = onMouseMoveScript;
1247 }
1248
1249
1250
1251
1252 @BeanTagAttribute(name = "templateOptions", type = BeanTagAttribute.AttributeType.MAPVALUE)
1253 public Map<String, String> getTemplateOptions() {
1254 if (templateOptions == null) {
1255 templateOptions = new HashMap<String, String>();
1256 }
1257 return this.templateOptions;
1258 }
1259
1260
1261
1262
1263 public void setTemplateOptions(Map<String, String> templateOptions) {
1264 this.templateOptions = templateOptions;
1265 }
1266
1267
1268
1269
1270
1271
1272
1273
1274 @Override
1275 @BeanTagAttribute(name = "templateOptionsJSString")
1276 public String getTemplateOptionsJSString() {
1277 if (templateOptionsJSString != null) {
1278 return templateOptionsJSString;
1279 }
1280
1281 if (templateOptions == null) {
1282 templateOptions = new HashMap<String, String>();
1283 }
1284 StringBuilder sb = new StringBuilder();
1285
1286 sb.append("{");
1287
1288 for (String optionKey : templateOptions.keySet()) {
1289 String optionValue = templateOptions.get(optionKey);
1290
1291 if (sb.length() > 1) {
1292 sb.append(",");
1293 }
1294
1295 sb.append(optionKey);
1296 sb.append(":");
1297
1298 sb.append(ScriptUtils.convertToJsValue(optionValue));
1299 }
1300
1301 sb.append("}");
1302
1303 return sb.toString();
1304 }
1305
1306 @Override
1307 public void setTemplateOptionsJSString(String templateOptionsJSString) {
1308 this.templateOptionsJSString = templateOptionsJSString;
1309 }
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331 @BeanTagAttribute(name = "progressiveRender")
1332 public String getProgressiveRender() {
1333 return this.progressiveRender;
1334 }
1335
1336
1337
1338
1339 public void setProgressiveRender(String progressiveRender) {
1340 this.progressiveRender = progressiveRender;
1341 }
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362 @BeanTagAttribute(name = "conditionalRefresh")
1363 public String getConditionalRefresh() {
1364 return this.conditionalRefresh;
1365 }
1366
1367
1368
1369
1370
1371
1372 public void setConditionalRefresh(String conditionalRefresh) {
1373 this.conditionalRefresh = conditionalRefresh;
1374 }
1375
1376
1377
1378
1379
1380
1381
1382 public List<String> getProgressiveDisclosureControlNames() {
1383 return this.progressiveDisclosureControlNames;
1384 }
1385
1386
1387
1388
1389
1390
1391
1392 public String getProgressiveDisclosureConditionJs() {
1393 return this.progressiveDisclosureConditionJs;
1394 }
1395
1396
1397
1398
1399
1400
1401
1402 public String getConditionalRefreshConditionJs() {
1403 return this.conditionalRefreshConditionJs;
1404 }
1405
1406
1407
1408
1409
1410
1411
1412 public List<String> getConditionalRefreshControlNames() {
1413 return this.conditionalRefreshControlNames;
1414 }
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427 @BeanTagAttribute(name = "progressiveRenderViaAJAX")
1428 public boolean isProgressiveRenderViaAJAX() {
1429 return this.progressiveRenderViaAJAX;
1430 }
1431
1432
1433
1434
1435 public void setProgressiveRenderViaAJAX(boolean progressiveRenderViaAJAX) {
1436 this.progressiveRenderViaAJAX = progressiveRenderViaAJAX;
1437 }
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451 @BeanTagAttribute(name = "progressiveRenderAndRefresh")
1452 public boolean isProgressiveRenderAndRefresh() {
1453 return this.progressiveRenderAndRefresh;
1454 }
1455
1456
1457
1458
1459
1460
1461 public void setProgressiveRenderAndRefresh(boolean progressiveRenderAndRefresh) {
1462 this.progressiveRenderAndRefresh = progressiveRenderAndRefresh;
1463 }
1464
1465
1466
1467
1468 @BeanTagAttribute(name = "refreshWhenChangedPropertyNames", type = BeanTagAttribute.AttributeType.LISTVALUE)
1469 public List<String> getRefreshWhenChangedPropertyNames() {
1470 return this.refreshWhenChangedPropertyNames;
1471 }
1472
1473
1474
1475
1476 public void setRefreshWhenChangedPropertyNames(List<String> refreshWhenChangedPropertyNames) {
1477 this.refreshWhenChangedPropertyNames = refreshWhenChangedPropertyNames;
1478 }
1479
1480
1481
1482
1483 @BeanTagAttribute(name = "additionalComponentsToRefresh", type = BeanTagAttribute.AttributeType.LISTVALUE)
1484 public List<String> getAdditionalComponentsToRefresh() {
1485 return additionalComponentsToRefresh;
1486 }
1487
1488
1489
1490
1491 public void setAdditionalComponentsToRefresh(List<String> additionalComponentsToRefresh) {
1492 this.additionalComponentsToRefresh = additionalComponentsToRefresh;
1493 }
1494
1495
1496
1497
1498 public boolean isRefreshedByAction() {
1499 return refreshedByAction;
1500 }
1501
1502
1503
1504
1505 public void setRefreshedByAction(boolean refreshedByAction) {
1506 this.refreshedByAction = refreshedByAction;
1507 }
1508
1509
1510
1511
1512 public boolean isDisclosedByAction() {
1513 return disclosedByAction;
1514 }
1515
1516
1517
1518
1519 public void setDisclosedByAction(boolean disclosedByAction) {
1520 this.disclosedByAction = disclosedByAction;
1521 }
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533 @BeanTagAttribute(name = "refreshTimer")
1534 public int getRefreshTimer() {
1535 return refreshTimer;
1536 }
1537
1538
1539
1540
1541
1542
1543 public void setRefreshTimer(int refreshTimer) {
1544 this.refreshTimer = refreshTimer;
1545 }
1546
1547
1548
1549
1550 @BeanTagAttribute(name = "resetDataOnRefresh")
1551 public boolean isResetDataOnRefresh() {
1552 return resetDataOnRefresh;
1553 }
1554
1555
1556
1557
1558 public void setResetDataOnRefresh(boolean resetDataOnRefresh) {
1559 this.resetDataOnRefresh = resetDataOnRefresh;
1560 }
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579 @BeanTagAttribute(name = "methodToCallOnRefresh")
1580 public String getMethodToCallOnRefresh() {
1581 return methodToCallOnRefresh;
1582 }
1583
1584
1585
1586
1587
1588
1589 public void setMethodToCallOnRefresh(String methodToCallOnRefresh) {
1590 this.methodToCallOnRefresh = methodToCallOnRefresh;
1591 }
1592
1593
1594
1595
1596 public void setSkipInTabOrder(boolean skipInTabOrder) {
1597 this.skipInTabOrder = skipInTabOrder;
1598 }
1599
1600
1601
1602
1603
1604
1605
1606 @BeanTagAttribute(name = "skipInTabOrder")
1607 public boolean isSkipInTabOrder() {
1608 return skipInTabOrder;
1609 }
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621 @BeanTagAttribute(name = "dataAttributes", type = BeanTagAttribute.AttributeType.MAPVALUE)
1622 public Map<String, String> getDataAttributes() {
1623 return dataAttributes;
1624 }
1625
1626
1627
1628
1629
1630
1631 public void setDataAttributes(Map<String, String> dataAttributes) {
1632 this.dataAttributes = dataAttributes;
1633 }
1634
1635
1636
1637
1638
1639
1640
1641 public void addDataAttribute(String key, String value) {
1642 dataAttributes.put(key, value);
1643 }
1644
1645
1646
1647
1648
1649
1650
1651
1652 public void addDataAttributeIfNonEmpty(String key, String value) {
1653 if (StringUtils.isNotBlank(value)) {
1654 addDataAttribute(key, value);
1655 }
1656 }
1657
1658
1659
1660
1661
1662
1663
1664 public String getComplexDataAttributesJs() {
1665 String js = "";
1666 if (getDataAttributes() == null) {
1667 return js;
1668 } else {
1669 for (Map.Entry<String, String> data : getDataAttributes().entrySet()) {
1670 if (data != null && data.getValue() != null &&
1671 data.getValue().trim().startsWith("{") && data.getValue().trim().endsWith("}")) {
1672 js = js + "jQuery('#" + this.getId() + "').data('" + data.getKey() + "', " + data.getValue() + ");";
1673 }
1674 }
1675 return js;
1676 }
1677 }
1678
1679
1680
1681
1682
1683
1684
1685 public String getSimpleDataAttributes() {
1686 String attributes = "";
1687 if (getDataAttributes() == null) {
1688 return attributes;
1689 } else {
1690 for (Map.Entry<String, String> data : getDataAttributes().entrySet()) {
1691 if (data != null && data.getValue() != null && !data.getValue().trim().startsWith("{")) {
1692 attributes = attributes + " " + "data-" + data.getKey() + "=\"" + data.getValue() + "\"";
1693 }
1694 }
1695 return attributes;
1696 }
1697 }
1698
1699
1700
1701
1702 @Override
1703 public String getAllDataAttributesJs() {
1704 String js = "";
1705 if (getDataAttributes() == null) {
1706 return js;
1707 } else {
1708 for (Map.Entry<String, String> data : getDataAttributes().entrySet()) {
1709 js = js + "jQuery('#" + this.getId() + "').data('" + data.getKey() + "', " + ScriptUtils
1710 .convertToJsValue(data.getValue()) + ");";
1711 }
1712 return js;
1713 }
1714 }
1715
1716
1717
1718
1719 public String getAdditionalComponentsToRefreshJs() {
1720 if (!(this.getAdditionalComponentsToRefresh().isEmpty())) {
1721 additionalComponentsToRefreshJs = ScriptUtils.convertStringListToJsArray(
1722 this.getAdditionalComponentsToRefresh());
1723 }
1724
1725 return additionalComponentsToRefreshJs;
1726 }
1727
1728
1729
1730
1731 public void completeValidation(ValidationTrace tracer) {
1732 tracer.addBean(this);
1733
1734
1735 if (getId() != null) {
1736 if (getId().contains("'")
1737 || getId().contains("\"")
1738 || getId().contains("[]")
1739 || getId().contains(".")
1740 || getId().contains("#")) {
1741 String currentValues[] = {"id = " + getId()};
1742 tracer.createError("Id contains invalid characters", currentValues);
1743 }
1744 }
1745
1746 if (tracer.getValidationStage() == ValidationTrace.BUILD) {
1747
1748 if ((isProgressiveRenderViaAJAX() || isProgressiveRenderAndRefresh()) && (getProgressiveRender() == null)) {
1749 String currentValues[] = {"progressiveRenderViaAJAX = " + isProgressiveRenderViaAJAX(),
1750 "progressiveRenderAndRefresh = " + isProgressiveRenderAndRefresh(),
1751 "progressiveRender = " + getProgressiveRender()};
1752 tracer.createError(
1753 "ProgressiveRender must be set if progressiveRenderViaAJAX or progressiveRenderAndRefresh are true",
1754 currentValues);
1755 }
1756 }
1757
1758
1759 if (isSelfRendered() && getRenderedHtmlOutput() == null) {
1760 String currentValues[] =
1761 {"selfRendered = " + isSelfRendered(), "renderedHtmlOutput = " + getRenderedHtmlOutput()};
1762 tracer.createError("RenderedHtmlOutput must be set if selfRendered is true", currentValues);
1763 }
1764
1765
1766 if (isDisableSessionPersistence() && isForceSessionPersistence()) {
1767 String currentValues[] = {"disableSessionPersistence = " + isDisableSessionPersistence(),
1768 "forceSessionPersistence = " + isForceSessionPersistence()};
1769 tracer.createWarning("DisableSessionPersistence and forceSessionPersistence cannot be both true",
1770 currentValues);
1771 }
1772
1773
1774 if (getMethodToCallOnRefresh() != null || isResetDataOnRefresh()) {
1775 if (!isProgressiveRenderAndRefresh()
1776 && !isRefreshedByAction()
1777 && !isProgressiveRenderViaAJAX()
1778 && !StringUtils.isNotEmpty(conditionalRefresh)
1779 && !(refreshTimer > 0)) {
1780 String currentValues[] = {"methodToCallONRefresh = " + getMethodToCallOnRefresh(),
1781 "resetDataONRefresh = " + isResetDataOnRefresh(),
1782 "progressiveRenderAndRefresh = " + isProgressiveRenderAndRefresh(),
1783 "refreshedByAction = " + isRefreshedByAction(),
1784 "progressiveRenderViaAJAX = " + isProgressiveRenderViaAJAX(),
1785 "conditionalRefresh = " + getConditionalRefresh(), "refreshTimer = " + getRefreshTimer()};
1786 tracer.createWarning(
1787 "MethodToCallONRefresh and resetDataONRefresh should only be set when a trigger event is set",
1788 currentValues);
1789 }
1790 }
1791
1792
1793 if (StringUtils.isNotEmpty(getProgressiveRender()) && StringUtils.isNotEmpty(conditionalRefresh)) {
1794 String currentValues[] = {"progressiveRender = " + getProgressiveRender(),
1795 "conditionalRefresh = " + getConditionalRefresh()};
1796 tracer.createWarning("DO NOT use progressiveRender and conditionalRefresh on the same component unless "
1797 + "it is known that the component will always be visible in all cases when a conditionalRefresh "
1798 + "happens (ie conditionalRefresh has progressiveRender's condition anded with its own condition). "
1799 + "If a component should be refreshed every time it is shown, use the progressiveRenderAndRefresh "
1800 + "option with this property instead.", currentValues);
1801 }
1802
1803
1804 if (!Validator.validateSpringEL(getProgressiveRender())) {
1805 String currentValues[] = {"progressiveRender =" + getProgressiveRender()};
1806 tracer.createError("ProgressiveRender must follow the Spring EL @{} format", currentValues);
1807 }
1808
1809
1810 if (!Validator.validateSpringEL(getConditionalRefresh())) {
1811 String currentValues[] = {"conditionalRefresh =" + getConditionalRefresh()};
1812 tracer.createError("conditionalRefresh must follow the Spring EL @{} format", currentValues);
1813 ;
1814 }
1815 }
1816
1817 }