1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.widget;
17
18 import org.apache.commons.lang.ClassUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.CoreApiServiceLocator;
21 import org.kuali.rice.core.api.config.property.ConfigurationService;
22 import org.kuali.rice.core.api.util.type.KualiDecimal;
23 import org.kuali.rice.core.api.util.type.KualiInteger;
24 import org.kuali.rice.core.api.util.type.KualiPercent;
25 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
26 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
27 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
28 import org.kuali.rice.krad.uif.UifConstants;
29 import org.kuali.rice.krad.uif.UifParameters;
30 import org.kuali.rice.krad.uif.component.Component;
31 import org.kuali.rice.krad.uif.component.ComponentBase;
32 import org.kuali.rice.krad.uif.container.CollectionGroup;
33 import org.kuali.rice.krad.uif.control.CheckboxControl;
34 import org.kuali.rice.krad.uif.control.CheckboxGroupControl;
35 import org.kuali.rice.krad.uif.control.Control;
36 import org.kuali.rice.krad.uif.control.RadioGroupControl;
37 import org.kuali.rice.krad.uif.control.SelectControl;
38 import org.kuali.rice.krad.uif.field.DataField;
39 import org.kuali.rice.krad.uif.field.Field;
40 import org.kuali.rice.krad.uif.field.FieldGroup;
41 import org.kuali.rice.krad.uif.field.InputField;
42 import org.kuali.rice.krad.uif.field.LinkField;
43 import org.kuali.rice.krad.uif.field.MessageField;
44 import org.kuali.rice.krad.uif.layout.LayoutManager;
45 import org.kuali.rice.krad.uif.layout.TableLayoutManager;
46 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
47 import org.kuali.rice.krad.uif.view.View;
48 import org.kuali.rice.krad.util.KRADConstants;
49 import org.kuali.rice.krad.util.KRADUtils;
50 import org.kuali.rice.krad.web.form.UifFormBase;
51
52 import java.sql.Timestamp;
53 import java.util.ArrayList;
54 import java.util.HashSet;
55 import java.util.List;
56 import java.util.Set;
57
58
59
60
61
62
63
64
65
66
67
68 @BeanTags({@BeanTag(name = "richTable-bean", parent = "Uif-RichTable"),
69 @BeanTag(name = "pagedRichTable-bean", parent = "Uif-PagedRichTable"),
70 @BeanTag(name = "scrollableRichTable-bean", parent = "Uif-ScrollableRichTable")})
71 public class RichTable extends WidgetBase {
72 private static final long serialVersionUID = 4671589690877390070L;
73
74 private String emptyTableMessage;
75 private boolean disableTableSort;
76
77 private boolean forceAoColumnDefsOverride;
78
79 private boolean forceAjaxJsonData;
80 private boolean forceLocalJsonData;
81 private int nestedLevel;
82 private String aaData;
83
84 private Set<String> hiddenColumns;
85 private Set<String> sortableColumns;
86 private List<String> cellCssClasses;
87
88 private String ajaxSource;
89
90 private boolean showSearchAndExportOptions = true;
91 private boolean showSearchOption = false;
92 private boolean showExportOption = false;
93
94 private String groupingOptionsJSString;
95
96 public RichTable() {
97 super();
98 groupingOptionsJSString = "null";
99 cellCssClasses = new ArrayList<String>();
100 }
101
102
103
104
105
106
107
108
109 @Override
110 public void performFinalize(View view, Object model, Component component) {
111 super.performFinalize(view, model, component);
112
113 UifFormBase formBase = (UifFormBase) model;
114
115 if (!isRender()) {
116 return;
117 }
118
119 if (StringUtils.isNotBlank(getEmptyTableMessage()) && !getTemplateOptions().containsKey(
120 UifConstants.TableToolsKeys.LANGUAGE)) {
121 getTemplateOptions().put(UifConstants.TableToolsKeys.LANGUAGE,
122 "{\"" + UifConstants.TableToolsKeys.EMPTY_TABLE + "\" : \"" + getEmptyTableMessage() + "\"}");
123 }
124
125 if (!isShowSearchAndExportOptions()) {
126 Object domOption = getTemplateOptions().get(UifConstants.TableToolsKeys.SDOM);
127 if (domOption instanceof String) {
128 String sDomOption = (String) domOption;
129
130 if (StringUtils.isNotBlank(sDomOption)) {
131 if (!isShowExportOption()) {
132 sDomOption = StringUtils.remove(sDomOption, "T");
133 }
134 if (!isShowSearchOption()) {
135 sDomOption = StringUtils.remove(sDomOption, "f");
136 }
137 getTemplateOptions().put(UifConstants.TableToolsKeys.SDOM, sDomOption);
138 }
139 }
140 }
141
142
143 if (UifConstants.ActionEvents.ADD_LINE.equals(formBase.getActionEvent()) || UifConstants.ActionEvents
144 .ADD_BLANK_LINE.equals(formBase.getActionEvent())) {
145 getTemplateOptions().put(UifConstants.TableToolsKeys.AASORTING, "[]");
146 }
147
148 if ((component instanceof CollectionGroup)) {
149 LayoutManager layoutManager = ((CollectionGroup) component).getLayoutManager();
150
151
152
153 if (layoutManager instanceof TableLayoutManager && (this.forceAjaxJsonData || this.forceLocalJsonData)) {
154 addCellStyling((TableLayoutManager) layoutManager);
155 }
156
157 buildTableOptions((CollectionGroup) component);
158 setTotalOptions((CollectionGroup) component);
159 }
160
161 if (isDisableTableSort()) {
162 getTemplateOptions().put(UifConstants.TableToolsKeys.TABLE_SORT, "false");
163 }
164
165 String kradUrl = getConfigurationService().getPropertyValueAsString(UifConstants.ConfigProperties.KRAD_URL);
166 if (StringUtils.isNotBlank(ajaxSource)) {
167 getTemplateOptions().put(UifConstants.TableToolsKeys.SAJAX_SOURCE, ajaxSource);
168 } else if (component instanceof CollectionGroup && this.forceAjaxJsonData) {
169
170 getTemplateOptions().put(UifConstants.TableToolsKeys.SAJAX_SOURCE, kradUrl
171 + ((UifFormBase) model).getControllerMapping()
172 + "?"
173 + UifConstants.CONTROLLER_METHOD_DISPATCH_PARAMETER_NAME
174 + "="
175 + UifConstants.MethodToCallNames.TABLE_JSON
176 + "&"
177 + UifParameters.TABLE_ID
178 + "="
179 + component.getId()
180 + "&"
181 + UifParameters.FORM_KEY
182 + "="
183 + ((UifFormBase) model).getFormKey()
184 + "&"
185 + UifParameters.AJAX_RETURN_TYPE
186 + "="
187 + UifConstants.AjaxReturnTypes.UPDATENONE.getKey()
188 + "&"
189 + UifParameters.AJAX_REQUEST
190 + "="
191 + "true");
192 }
193
194
195 getTemplateOptions().put(UifConstants.TableToolsKeys.SDOWNLOAD_SOURCE, kradUrl
196 + ((UifFormBase) model).getControllerMapping()
197 + "?"
198 + UifConstants.CONTROLLER_METHOD_DISPATCH_PARAMETER_NAME
199 + "="
200 + UifConstants.MethodToCallNames.TABLE_DATA
201 + "&"
202 + UifParameters.TABLE_ID
203 + "="
204 + component.getId()
205 + "&"
206 + UifParameters.FORM_KEY
207 + "="
208 + ((UifFormBase) model).getFormKey()
209 + "&"
210 + UifParameters.AJAX_RETURN_TYPE
211 + "="
212 + UifConstants.AjaxReturnTypes.UPDATENONE.getKey()
213 + "&"
214 + UifParameters.AJAX_REQUEST
215 + "="
216 + "true");
217
218 }
219
220
221
222
223
224
225 private void addCellStyling(TableLayoutManager manager) {
226 if (manager.getAllRowFields() != null) {
227 for (int index = 0; index < manager.getNumberOfColumns(); index++) {
228 String cellStyleClasses = ((ComponentBase) manager.getAllRowFields().get(index))
229 .getCellStyleClassesAsString();
230 cellCssClasses.add(cellStyleClasses);
231 }
232 }
233 }
234
235
236
237
238
239
240 private void setTotalOptions(CollectionGroup collectionGroup) {
241 LayoutManager layoutManager = collectionGroup.getLayoutManager();
242
243 if (layoutManager instanceof TableLayoutManager) {
244 List<String> totalColumns = ((TableLayoutManager) layoutManager).getColumnsToCalculate();
245
246 if (totalColumns.size() > 0) {
247 String array = "[";
248
249 for (String i : totalColumns) {
250 array = array + i + ",";
251 }
252 array = StringUtils.removeEnd(array, ",");
253 array = array + "]";
254 getTemplateOptions().put(UifConstants.TableToolsKeys.FOOTER_CALLBACK,
255 "function (nRow, aaData, iStart, iEnd, aiDisplay) {initializeTotalsFooter (nRow, aaData, iStart, iEnd, aiDisplay, "
256 + array
257 + " )}");
258 }
259 }
260 }
261
262
263
264
265
266
267 protected void buildTableOptions(CollectionGroup collectionGroup) {
268 LayoutManager layoutManager = collectionGroup.getLayoutManager();
269
270
271 if (!collectionGroup.getSubCollections().isEmpty()) {
272 setDisableTableSort(true);
273 }
274
275 if (!isDisableTableSort()) {
276
277 if (collectionGroup.isRenderAddLine()
278 && !collectionGroup.isReadOnly()
279 && !((layoutManager instanceof TableLayoutManager) && ((TableLayoutManager) layoutManager)
280 .isSeparateAddLine())) {
281 getTemplateOptions().put(UifConstants.TableToolsKeys.SORT_SKIP_ROWS,
282 "[" + UifConstants.TableToolsValues.ADD_ROW_DEFAULT_INDEX + "]");
283 }
284
285 StringBuffer tableToolsColumnOptions = new StringBuffer("[");
286
287 int columnIndex = 0;
288 int actionIndex = UifConstants.TableLayoutValues.ACTIONS_COLUMN_RIGHT_INDEX;
289 boolean actionFieldVisible = collectionGroup.isRenderLineActions() && !collectionGroup.isReadOnly();
290
291 if (layoutManager instanceof TableLayoutManager) {
292 actionIndex = ((TableLayoutManager) layoutManager).getActionColumnIndex();
293 }
294
295 if (actionIndex == UifConstants.TableLayoutValues.ACTIONS_COLUMN_LEFT_INDEX && actionFieldVisible) {
296 String actionColOptions = constructTableColumnOptions(columnIndex, false, null, null);
297 tableToolsColumnOptions.append(actionColOptions + " , ");
298 columnIndex++;
299 }
300
301 if (layoutManager instanceof TableLayoutManager && ((TableLayoutManager) layoutManager)
302 .isRenderSequenceField()) {
303
304
305 String mDataOption = "";
306 if (this.forceAjaxJsonData || this.forceLocalJsonData) {
307 mDataOption = "\""
308 + UifConstants.TableToolsKeys.MDATA
309 +
310 "\" : function(row,type,newVal){ return _handleColData(row,type,'c"
311 + columnIndex
312 + "',newVal);}, ";
313 }
314
315 tableToolsColumnOptions.append("{\""
316 + UifConstants.TableToolsKeys.SORT_TYPE
317 + "\" : \""
318 + UifConstants.TableToolsValues.NUMERIC
319 + "\", "
320 + mDataOption
321 + "\""
322 + UifConstants.TableToolsKeys.TARGETS
323 + "\": ["
324 + columnIndex
325 + "]}, ");
326 columnIndex++;
327 if (actionIndex == 2 && actionFieldVisible) {
328 String actionColOptions = constructTableColumnOptions(columnIndex, false, null, null);
329 tableToolsColumnOptions.append(actionColOptions + " , ");
330 columnIndex++;
331 }
332 }
333
334
335 if (collectionGroup.isIncludeLineSelectionField()) {
336 String colOptions = constructTableColumnOptions(columnIndex, false, null, null);
337 tableToolsColumnOptions.append(colOptions + " , ");
338 columnIndex++;
339 }
340
341
342 if (!StringUtils.isEmpty(getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMNS))) {
343
344 String jsArray = getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMNS);
345 int startBrace = StringUtils.indexOf(jsArray, "[");
346 int endBrace = StringUtils.lastIndexOf(jsArray, "]");
347 tableToolsColumnOptions.append(StringUtils.substring(jsArray, startBrace + 1, endBrace) + ", ");
348
349 if (actionFieldVisible && (actionIndex == -1 || actionIndex >= columnIndex)) {
350 String actionColOptions = constructTableColumnOptions(columnIndex, false, null, null);
351 tableToolsColumnOptions.append(actionColOptions);
352 } else {
353 tableToolsColumnOptions = new StringBuffer(StringUtils.removeEnd(tableToolsColumnOptions.toString(),
354 ", "));
355 }
356
357 tableToolsColumnOptions.append("]");
358 getTemplateOptions().put(UifConstants.TableToolsKeys.AO_COLUMNS, tableToolsColumnOptions.toString());
359 } else if (!StringUtils.isEmpty(getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS))
360 && forceAoColumnDefsOverride) {
361 String jsArray = getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS);
362 int startBrace = StringUtils.indexOf(jsArray, "[");
363 int endBrace = StringUtils.lastIndexOf(jsArray, "]");
364 tableToolsColumnOptions.append(StringUtils.substring(jsArray, startBrace + 1, endBrace) + ", ");
365
366 if (actionFieldVisible && (actionIndex == -1 || actionIndex >= columnIndex)) {
367 String actionColOptions = constructTableColumnOptions(columnIndex, false, null, null);
368 tableToolsColumnOptions.append(actionColOptions);
369 } else {
370 tableToolsColumnOptions = new StringBuffer(StringUtils.removeEnd(tableToolsColumnOptions.toString(),
371 ", "));
372 }
373
374 tableToolsColumnOptions.append("]");
375 getTemplateOptions().put(UifConstants.TableToolsKeys.AO_COLUMN_DEFS,
376 tableToolsColumnOptions.toString());
377 } else if (layoutManager instanceof TableLayoutManager) {
378 List<Field> rowFields = ((TableLayoutManager) layoutManager).getFirstRowFields();
379
380
381 for (Component component : rowFields) {
382 if (actionFieldVisible && columnIndex + 1 == actionIndex) {
383 String actionColOptions = constructTableColumnOptions(columnIndex, false, null, null);
384 tableToolsColumnOptions.append(actionColOptions + " , ");
385 columnIndex++;
386 }
387
388
389 String mDataOption = "";
390 if (this.forceAjaxJsonData || this.forceLocalJsonData) {
391 mDataOption = "\""
392 + UifConstants.TableToolsKeys.MDATA
393 +
394 "\" : function(row,type,newVal){ return _handleColData(row,type,'c"
395 + columnIndex
396 + "',newVal);}, ";
397 }
398
399
400 if (component instanceof FieldGroup) {
401 component = ((FieldGroup) component).getItems().get(0);
402 }
403
404 if (component instanceof DataField) {
405 DataField field = (DataField) component;
406
407
408 if (getHiddenColumns() != null && getHiddenColumns().contains(field.getPropertyName())) {
409 tableToolsColumnOptions.append("{"
410 + UifConstants.TableToolsKeys.VISIBLE
411 + ": "
412 + UifConstants.TableToolsValues.FALSE
413 + ", "
414 + mDataOption
415 + "\""
416 + UifConstants.TableToolsKeys.TARGETS
417 + "\": ["
418 + columnIndex
419 + "]"
420 + "}, ");
421
422 } else if (getSortableColumns() != null && !getSortableColumns().isEmpty()) {
423 if (getSortableColumns().contains(field.getPropertyName())) {
424 tableToolsColumnOptions.append(getDataFieldColumnOptions(columnIndex, collectionGroup,
425 field) + ", ");
426 } else {
427 tableToolsColumnOptions.append("{'"
428 + UifConstants.TableToolsKeys.SORTABLE
429 + "': "
430 + UifConstants.TableToolsValues.FALSE
431 + ", "
432 + mDataOption
433 + "\""
434 + UifConstants.TableToolsKeys.TARGETS
435 + "\": ["
436 + columnIndex
437 + "]"
438 + "}, ");
439 }
440 } else {
441 String colOptions = getDataFieldColumnOptions(columnIndex, collectionGroup, field);
442 tableToolsColumnOptions.append(colOptions + " , ");
443 }
444 columnIndex++;
445 } else if (component instanceof MessageField
446 && component.getDataAttributes().get("role") != null
447 && component.getDataAttributes().get("role").equals("grouping")) {
448
449 tableToolsColumnOptions.append("{"
450 + UifConstants.TableToolsKeys.VISIBLE
451 + ": "
452 + UifConstants.TableToolsValues.FALSE
453 + ", "
454 + mDataOption
455 + "\""
456 + UifConstants.TableToolsKeys.TARGETS
457 + "\": ["
458 + columnIndex
459 + "]"
460 + "}, ");
461 columnIndex++;
462 } else if (component instanceof LinkField) {
463 String colOptions = constructTableColumnOptions(columnIndex, true, String.class,
464 UifConstants.TableToolsValues.DOM_TEXT);
465 tableToolsColumnOptions.append(colOptions + " , ");
466 columnIndex++;
467 } else {
468 String colOptions = constructTableColumnOptions(columnIndex, false, null, null);
469 tableToolsColumnOptions.append(colOptions + " , ");
470 columnIndex++;
471 }
472 }
473
474 if (actionFieldVisible && (actionIndex == -1 || actionIndex >= columnIndex)) {
475 String actionColOptions = constructTableColumnOptions(columnIndex, false, null, null);
476 tableToolsColumnOptions.append(actionColOptions);
477 } else {
478 tableToolsColumnOptions = new StringBuffer(StringUtils.removeEnd(tableToolsColumnOptions.toString(),
479 ", "));
480 }
481
482
483 if (!StringUtils.isEmpty(getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS))) {
484 String origAoOptions = getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS).trim();
485 origAoOptions = StringUtils.removeStart(origAoOptions, "[");
486 origAoOptions = StringUtils.removeEnd(origAoOptions, "]");
487 tableToolsColumnOptions.append("," + origAoOptions);
488 }
489
490 tableToolsColumnOptions.append("]");
491 getTemplateOptions().put(UifConstants.TableToolsKeys.AO_COLUMN_DEFS,
492 tableToolsColumnOptions.toString());
493 }
494 }
495 }
496
497
498
499
500
501
502
503
504 protected String getDataFieldColumnOptions(int target, CollectionGroup collectionGroup, DataField field) {
505 String sortType = null;
506
507 if (!collectionGroup.isReadOnly()
508 && (field instanceof InputField)
509 && ((InputField) field).getControl() != null) {
510 Control control = ((InputField) field).getControl();
511 if (control instanceof SelectControl) {
512 sortType = UifConstants.TableToolsValues.DOM_SELECT;
513 } else if (control instanceof CheckboxControl || control instanceof CheckboxGroupControl) {
514 sortType = UifConstants.TableToolsValues.DOM_CHECK;
515 } else if (control instanceof RadioGroupControl) {
516 sortType = UifConstants.TableToolsValues.DOM_RADIO;
517 } else {
518 sortType = UifConstants.TableToolsValues.DOM_TEXT;
519 }
520 } else {
521 sortType = UifConstants.TableToolsValues.DOM_TEXT;
522 }
523
524 Class dataTypeClass = ObjectPropertyUtils.getPropertyType(collectionGroup.getCollectionObjectClass(),
525 field.getPropertyName());
526
527 boolean isSortable = true;
528 if (field.isApplyMask()) {
529 isSortable = false;
530 }
531
532 return constructTableColumnOptions(target, isSortable, dataTypeClass, sortType);
533 }
534
535
536
537
538
539
540
541
542
543
544
545
546 public String constructTableColumnOptions(int target, boolean isSortable, Class dataTypeClass,
547 String sortDataType) {
548 String colOptions = "null";
549
550 String sortType = "";
551 if (!isSortable || dataTypeClass == null || sortType == null) {
552 colOptions = "\"" + UifConstants.TableToolsKeys.SORTABLE + "\" : false, \"sType\" : \"string\"";
553 } else {
554 if (ClassUtils.isAssignable(dataTypeClass, KualiPercent.class)) {
555 sortType = UifConstants.TableToolsValues.PERCENT;
556 } else if (ClassUtils.isAssignable(dataTypeClass, KualiInteger.class) || ClassUtils.isAssignable(
557 dataTypeClass, KualiDecimal.class)) {
558 sortType = UifConstants.TableToolsValues.CURRENCY;
559 } else if (ClassUtils.isAssignable(dataTypeClass, Timestamp.class)) {
560 sortType = "date";
561 } else if (ClassUtils.isAssignable(dataTypeClass, java.sql.Date.class) || ClassUtils.isAssignable(
562 dataTypeClass, java.util.Date.class)) {
563 sortType = UifConstants.TableToolsValues.DATE;
564 } else if (ClassUtils.isAssignable(dataTypeClass, Number.class)) {
565 sortType = UifConstants.TableToolsValues.NUMERIC;
566 } else {
567 sortType = UifConstants.TableToolsValues.STRING;
568 }
569
570 colOptions = "\"" + UifConstants.TableToolsKeys.SORT_TYPE + "\" : \"" + sortType + "\"";
571
572 if (!this.forceAjaxJsonData && !this.forceLocalJsonData) {
573 colOptions += ", \"" + UifConstants.TableToolsKeys.SORT_DATA_TYPE + "\" : \"" + sortDataType + "\"";
574 }
575 }
576
577 if (target < cellCssClasses.size() && target >= 0) {
578 colOptions += ", \""
579 + UifConstants.TableToolsKeys.CELL_CLASS
580 + "\" : \""
581 + cellCssClasses.get(target)
582 + "\"";
583 }
584
585
586 if (this.forceAjaxJsonData || this.forceLocalJsonData) {
587 colOptions += ", \"" + UifConstants.TableToolsKeys.MDATA +
588 "\" : function(row,type,newVal){ return _handleColData(row,type,'c" + target + "',newVal);}";
589 }
590
591 if (!colOptions.equals("null")) {
592 colOptions = "{" + colOptions + ", \"" + UifConstants.TableToolsKeys.TARGETS + "\": [" + target + "]}";
593 } else {
594 colOptions = "{" + colOptions + "}";
595 }
596
597 return colOptions;
598 }
599
600
601
602
603
604
605 @BeanTagAttribute(name = "emptyTableMessage")
606 public String getEmptyTableMessage() {
607 return emptyTableMessage;
608 }
609
610
611
612
613
614
615 public void setEmptyTableMessage(String emptyTableMessage) {
616 this.emptyTableMessage = emptyTableMessage;
617 }
618
619
620
621
622
623
624 @BeanTagAttribute(name = "disableTableSort")
625 public boolean isDisableTableSort() {
626 return this.disableTableSort;
627 }
628
629
630
631
632
633
634 public void setDisableTableSort(boolean disableTableSort) {
635 this.disableTableSort = disableTableSort;
636 }
637
638
639
640
641
642
643 @BeanTagAttribute(name = "showSearchAndExportOptions")
644 public boolean isShowSearchAndExportOptions() {
645 return this.showSearchAndExportOptions;
646 }
647
648
649
650
651
652
653 @BeanTagAttribute(name = "showSearchOption")
654 public boolean isShowSearchOption() {
655 return this.showSearchOption;
656 }
657
658
659
660
661
662
663 @BeanTagAttribute(name = "showExportOption")
664 public boolean isShowExportOption() {
665 return this.showExportOption;
666 }
667
668
669
670
671
672
673
674 public void setShowSearchAndExportOptions(boolean showSearchAndExportOptions) {
675 this.showSearchAndExportOptions = showSearchAndExportOptions;
676 }
677
678
679
680
681
682
683 public void setShowSearchOption(boolean showSearchOption) {
684 this.showSearchOption = showSearchOption;
685 }
686
687
688
689
690
691
692 public void setShowExportOption(boolean showExportOption) {
693 this.showExportOption = showExportOption;
694 }
695
696
697
698
699
700
701
702
703 @BeanTagAttribute(name = "hiddenColumns", type = BeanTagAttribute.AttributeType.SETVALUE)
704 public Set<String> getHiddenColumns() {
705 return hiddenColumns;
706 }
707
708
709
710
711
712
713 public void setHiddenColumns(Set<String> hiddenColumns) {
714 this.hiddenColumns = hiddenColumns;
715 }
716
717
718
719
720
721
722
723
724 @BeanTagAttribute(name = "sortableColumns", type = BeanTagAttribute.AttributeType.SETVALUE)
725 public Set<String> getSortableColumns() {
726 return sortableColumns;
727 }
728
729
730
731
732
733
734 public void setSortableColumns(Set<String> sortableColumns) {
735 this.sortableColumns = sortableColumns;
736 }
737
738
739
740
741
742
743
744
745
746
747
748
749 @BeanTagAttribute(name = "ajaxSource")
750 public String getAjaxSource() {
751 return ajaxSource;
752 }
753
754
755
756
757
758
759 public void setAjaxSource(String ajaxSource) {
760 this.ajaxSource = ajaxSource;
761 }
762
763
764
765
766
767
768 public String getGroupingOptionsJSString() {
769 return groupingOptionsJSString;
770 }
771
772
773
774
775
776
777 public void setGroupingOptionsJSString(String groupingOptionsJSString) {
778 this.groupingOptionsJSString = groupingOptionsJSString;
779 }
780
781
782
783
784
785
786
787
788
789 public boolean isForceAoColumnDefsOverride() {
790 return forceAoColumnDefsOverride;
791 }
792
793
794
795
796
797
798 public void setForceAoColumnDefsOverride(boolean forceAoColumnDefsOverride) {
799 this.forceAoColumnDefsOverride = forceAoColumnDefsOverride;
800 }
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819 public boolean isForceAjaxJsonData() {
820 return forceAjaxJsonData;
821 }
822
823
824
825
826
827
828 public void setForceAjaxJsonData(boolean forceAjaxJsonData) {
829 this.forceAjaxJsonData = forceAjaxJsonData;
830 }
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845 public boolean isForceLocalJsonData() {
846 return forceLocalJsonData;
847 }
848
849
850
851
852
853
854 public void setForceLocalJsonData(boolean forceLocalJsonData) {
855 this.forceLocalJsonData = forceLocalJsonData;
856 }
857
858
859
860
861
862
863
864
865
866
867
868 public int getNestedLevel() {
869 return nestedLevel;
870 }
871
872
873
874
875
876
877
878 public void setNestedLevel(int nestedLevel) {
879 this.nestedLevel = nestedLevel;
880 }
881
882
883
884
885
886
887
888
889
890
891 public String getAaData() {
892 return aaData;
893 }
894
895
896
897
898
899
900
901
902
903
904 public void setAaData(String aaData) {
905 this.aaData = aaData;
906 }
907
908
909
910
911
912
913
914
915
916
917 public String getCellValue(Object model, Field field) {
918 String value = KRADUtils.getSimpleFieldValue(model, field);
919
920 if (value == null) {
921 value = "null";
922 } else {
923 value = KRADConstants.QUOTE_PLACEHOLDER + value + KRADConstants.QUOTE_PLACEHOLDER;
924 }
925
926 return value;
927 }
928
929
930
931
932
933
934
935
936
937
938 public void addRowToTableData(String row) {
939 String escape = "";
940
941
942 for (int i = 0; i < nestedLevel && forceLocalJsonData; i++) {
943 escape = escape + "\\";
944 }
945
946
947 row = row.trim().replace("\"", escape + "\\u0022").replace("'", escape + "\\u0027").replace("\n", "").replace(
948 "\r", "");
949
950
951 row = StringUtils.removeEnd(row, ",");
952
953
954 row = row.replace(KRADConstants.QUOTE_PLACEHOLDER, "\"");
955 row = "{" + row + "}";
956
957
958 if (StringUtils.isBlank(aaData)) {
959 aaData = "[" + row + "]";
960
961 if (this.getTemplateOptions().get(UifConstants.TableToolsKeys.DEFER_RENDER) == null) {
962
963 this.getTemplateOptions().put(UifConstants.TableToolsKeys.DEFER_RENDER,
964 UifConstants.TableToolsValues.TRUE);
965 }
966 } else if (StringUtils.isNotBlank(row)) {
967 aaData = aaData.substring(0, aaData.length() - 1) + "," + row + "]";
968 }
969
970
971 if (forceLocalJsonData && !forceAjaxJsonData) {
972 this.getTemplateOptions().put(UifConstants.TableToolsKeys.AA_DATA, aaData);
973 }
974 }
975
976 protected ConfigurationService getConfigurationService() {
977 return CoreApiServiceLocator.getKualiConfigurationService();
978 }
979
980
981
982
983 @Override
984 protected <T> void copyProperties(T component) {
985 super.copyProperties(component);
986 RichTable richTableCopy = (RichTable) component;
987 richTableCopy.setEmptyTableMessage(this.getEmptyTableMessage());
988 richTableCopy.setDisableTableSort(this.isDisableTableSort());
989 richTableCopy.setForceAoColumnDefsOverride(this.isForceAoColumnDefsOverride());
990 richTableCopy.setForceAjaxJsonData(this.isForceAjaxJsonData());
991 richTableCopy.setForceLocalJsonData(this.isForceLocalJsonData());
992 richTableCopy.setNestedLevel(this.getNestedLevel());
993 richTableCopy.setAaData(this.getAaData());
994
995 if (hiddenColumns != null) {
996 richTableCopy.setHiddenColumns(new HashSet<String>(hiddenColumns));
997 }
998
999 if (sortableColumns != null) {
1000 richTableCopy.setSortableColumns(new HashSet<String>(sortableColumns));
1001 }
1002
1003 if (cellCssClasses != null) {
1004 richTableCopy.setCssClasses(new ArrayList<String>(this.cellCssClasses));
1005 }
1006
1007 richTableCopy.setAjaxSource(this.getAjaxSource());
1008 richTableCopy.setShowSearchAndExportOptions(this.isShowSearchAndExportOptions());
1009 richTableCopy.setShowSearchOption(this.isShowSearchOption());
1010 richTableCopy.setShowExportOption(this.isShowExportOption());
1011 richTableCopy.setGroupingOptionsJSString(this.getGroupingOptionsJSString());
1012 }
1013 }