1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.field;
17
18 import com.google.common.collect.Lists;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.uif.DataType;
21 import org.kuali.rice.core.api.util.ConcreteKeyValue;
22 import org.kuali.rice.core.api.util.KeyValue;
23 import org.kuali.rice.core.api.util.type.TypeUtils;
24 import org.kuali.rice.krad.datadictionary.AttributeDefinition;
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.datadictionary.state.StateMapping;
29 import org.kuali.rice.krad.datadictionary.validation.capability.CaseConstrainable;
30 import org.kuali.rice.krad.datadictionary.validation.capability.MustOccurConstrainable;
31 import org.kuali.rice.krad.datadictionary.validation.capability.PrerequisiteConstrainable;
32 import org.kuali.rice.krad.datadictionary.validation.capability.SimpleConstrainable;
33 import org.kuali.rice.krad.datadictionary.validation.capability.ValidCharactersConstrainable;
34 import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint;
35 import org.kuali.rice.krad.datadictionary.validation.constraint.MustOccurConstraint;
36 import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint;
37 import org.kuali.rice.krad.datadictionary.validation.constraint.SimpleConstraint;
38 import org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint;
39 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
40 import org.kuali.rice.krad.datadictionary.validator.Validator;
41 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
42 import org.kuali.rice.krad.uif.UifConstants;
43 import org.kuali.rice.krad.uif.component.Component;
44 import org.kuali.rice.krad.uif.control.Control;
45 import org.kuali.rice.krad.uif.control.MultiValueControlBase;
46 import org.kuali.rice.krad.uif.control.TextAreaControl;
47 import org.kuali.rice.krad.uif.control.TextControl;
48 import org.kuali.rice.krad.uif.control.UifKeyValuesFinder;
49 import org.kuali.rice.krad.uif.element.Label;
50 import org.kuali.rice.krad.uif.element.Message;
51 import org.kuali.rice.krad.uif.element.ValidationMessages;
52 import org.kuali.rice.krad.uif.util.ClientValidationUtils;
53 import org.kuali.rice.krad.uif.util.CloneUtils;
54 import org.kuali.rice.krad.uif.util.ComponentFactory;
55 import org.kuali.rice.krad.uif.util.ComponentUtils;
56 import org.kuali.rice.krad.uif.util.ConstraintStateUtils;
57 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
58 import org.kuali.rice.krad.uif.view.View;
59 import org.kuali.rice.krad.uif.view.ViewModel;
60 import org.kuali.rice.krad.uif.widget.QuickFinder;
61 import org.kuali.rice.krad.uif.widget.Suggest;
62 import org.kuali.rice.krad.util.ObjectUtils;
63
64 import java.util.ArrayList;
65 import java.util.List;
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 @BeanTags({@BeanTag(name = "inputField-bean", parent = "Uif-InputField"),
86 @BeanTag(name = "inputField-labelTop-bean", parent = "Uif-InputField-LabelTop"),
87 @BeanTag(name = "inputField-labelRight-bean", parent = "Uif-InputField-LabelRight"),
88 @BeanTag(name = "checkboxInputField-bean", parent = "Uif-CheckboxInputField"),
89 @BeanTag(name = "dialogResponse-bean", parent = "Uif-DialogResponse"),
90 @BeanTag(name = "dialogExplanation-bean", parent = "Uif-DialogExplanation"),
91 @BeanTag(name = "documentNumber-bean", parent = "Uif-DocumentNumber"),
92 @BeanTag(name = "documentStatus-bean", parent = "Uif-DocumentStatus"),
93 @BeanTag(name = "documentInitiatorNetworkId-bean", parent = "Uif-DocumentInitiatorNetworkId"),
94 @BeanTag(name = "documentCreateDate-bean", parent = "Uif-DocumentCreateDate"),
95 @BeanTag(name = "documentTemplateNumber-bean", parent = "Uif-DocumentTemplateNumber"),
96 @BeanTag(name = "documentDescription-bean", parent = "Uif-DocumentDescription"),
97 @BeanTag(name = "documentExplaination-bean", parent = "Uif-DocumentExplaination"),
98 @BeanTag(name = "organizationDocumentNumber-bean", parent = "Uif-OrganizationDocumentNumber"),
99 @BeanTag(name = "selectCollectionItemField-bean", parent = "Uif-SelectCollectionItemField")})
100 public class InputField extends DataField implements SimpleConstrainable, CaseConstrainable, PrerequisiteConstrainable, MustOccurConstrainable, ValidCharactersConstrainable {
101 private static final long serialVersionUID = -3703656713706343840L;
102
103
104 private String customValidatorClass;
105 private ValidCharactersConstraint validCharactersConstraint;
106 private CaseConstraint caseConstraint;
107 private List<PrerequisiteConstraint> dependencyConstraints;
108 private List<MustOccurConstraint> mustOccurConstraints;
109 private SimpleConstraint simpleConstraint;
110 private DataType dataType;
111
112
113 private Control control;
114 private KeyValuesFinder optionsFinder;
115
116 private boolean uppercaseValue;
117 private boolean disableNativeAutocomplete;
118
119 private ValidationMessages validationMessages;
120
121
122 private String constraintText;
123 private String instructionalText;
124
125 private Message constraintMessage;
126 private Message instructionalMessage;
127
128 private AttributeQuery attributeQuery;
129
130
131 private boolean enableAutoDirectInquiry;
132
133 private QuickFinder quickfinder;
134 private boolean enableAutoQuickfinder;
135
136 private Suggest suggest;
137
138 private boolean widgetInputOnly;
139
140 public InputField() {
141 super();
142
143 simpleConstraint = new SimpleConstraint();
144
145 enableAutoDirectInquiry = true;
146 enableAutoQuickfinder = true;
147 }
148
149
150
151
152
153
154
155
156
157
158
159 @Override
160 public void performInitialization(View view, Object model) {
161 super.performInitialization(view, model);
162
163 if ((StringUtils.isNotBlank(constraintText) || (getPropertyExpression("constraintText") != null)) && (
164 constraintMessage
165 == null)) {
166 constraintMessage = ComponentFactory.getConstraintMessage();
167 view.assignComponentIds(constraintMessage);
168 }
169
170 if ((StringUtils.isNotBlank(instructionalText) || (getPropertyExpression("instructionalText") != null)) && (
171 instructionalMessage
172 == null)) {
173 instructionalMessage = ComponentFactory.getInstructionalMessage();
174 view.assignComponentIds(instructionalMessage);
175 }
176
177 }
178
179
180
181
182 @Override
183 public void performApplyModel(View view, Object model, Component parent) {
184 super.performApplyModel(view, model, parent);
185
186
187
188 if (StringUtils.isNotBlank(instructionalText) && StringUtils.isBlank(instructionalMessage.getMessageText())) {
189 instructionalMessage.setMessageText(instructionalText);
190 }
191
192
193 if (StringUtils.isNotBlank(constraintText) && StringUtils.isBlank(constraintMessage.getMessageText())) {
194 constraintMessage.setMessageText(constraintText);
195 }
196
197
198 List<KeyValue> fieldOptions = new ArrayList<KeyValue>();
199
200
201 if ((control != null) && control instanceof MultiValueControlBase) {
202 MultiValueControlBase multiValueControl = (MultiValueControlBase) control;
203 if ((multiValueControl.getOptions() != null) && !multiValueControl.getOptions().isEmpty()) {
204 fieldOptions = multiValueControl.getOptions();
205 }
206 }
207
208
209 if (control instanceof TextAreaControl) {
210 setMultiLineReadOnlyDisplay(true);
211 }
212
213
214 if (fieldOptions.isEmpty() && (optionsFinder != null)) {
215 if (optionsFinder instanceof UifKeyValuesFinder) {
216 fieldOptions = ((UifKeyValuesFinder) optionsFinder).getKeyValues((ViewModel) model, this);
217
218
219 if (((UifKeyValuesFinder) optionsFinder).isAddBlankOption()) {
220 fieldOptions.add(0, new ConcreteKeyValue("", ""));
221 }
222 } else {
223 fieldOptions = optionsFinder.getKeyValues();
224 }
225
226 if ((control != null) && control instanceof MultiValueControlBase) {
227 ((MultiValueControlBase) control).setOptions(fieldOptions);
228 }
229 }
230
231 if (this.enableAutoDirectInquiry && (getInquiry() == null) && !isReadOnly()) {
232 buildAutomaticInquiry(view, model, true);
233 }
234
235 if (this.enableAutoQuickfinder && (getQuickfinder() == null)) {
236 buildAutomaticQuickfinder(view, model);
237 }
238
239
240 if (isReadOnly()
241 && !fieldOptions.isEmpty()
242 && StringUtils.isBlank(getReadOnlyDisplayReplacement())
243 && StringUtils.isBlank(getReadOnlyDisplaySuffix())
244 && StringUtils.isBlank(getReadOnlyDisplayReplacementPropertyName())
245 && StringUtils.isBlank(getReadOnlyDisplaySuffixPropertyName())) {
246
247 Object fieldValue = ObjectPropertyUtils.getPropertyValue(model, getBindingInfo().getBindingPath());
248
249
250 if ((fieldValue != null) && (TypeUtils.isSimpleType(fieldValue.getClass()))) {
251 for (KeyValue keyValue : fieldOptions) {
252 if (StringUtils.equals(fieldValue.toString(), keyValue.getKey())) {
253 setReadOnlyDisplayReplacement(keyValue.getValue());
254 break;
255 }
256 }
257 }
258 }
259 }
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274 @Override
275 public void performFinalize(View view, Object model, Component parent) {
276 super.performFinalize(view, model, parent);
277
278 setupIds();
279 this.addDataAttribute(UifConstants.DataAttributes.ROLE, UifConstants.RoleTypes.INPUT_FIELD);
280
281
282 if (isReadOnly() || getControl() == null) {
283 return;
284 }
285
286 if (uppercaseValue) {
287 Object currentPropertyValue = ObjectPropertyUtils.getPropertyValue(model, getBindingInfo().getBindingPath());
288 if (currentPropertyValue instanceof String) {
289 String uppercasedValue = ((String) currentPropertyValue).toUpperCase();
290 ObjectPropertyUtils.setPropertyValue(model, getBindingInfo().getBindingPath(), uppercasedValue);
291 }
292 }
293
294
295 if ((suggest != null) && suggest.isSuggestConfigured()) {
296 setDisableNativeAutocomplete(true);
297 }
298
299
300 adjustPrerequisiteConstraintBinding(dependencyConstraints);
301
302
303 adjustMustOccurConstraintBinding(mustOccurConstraints);
304
305
306 if (caseConstraint != null) {
307 String propertyName = getBindingInfo().getPropertyAdjustedBindingPath(caseConstraint.getPropertyName());
308 caseConstraint.setPropertyName(propertyName);
309 }
310
311 setupFieldQuery();
312
313
314
315 String path = view.getStateObjectBindingPath();
316 Object stateObject;
317
318 if (StringUtils.isNotBlank(path)) {
319 stateObject = ObjectPropertyUtils.getPropertyValue(model, path);
320 } else {
321 stateObject = model;
322 }
323 StateMapping stateMapping = view.getStateMapping();
324
325 if (stateMapping != null) {
326 String validationState = ConstraintStateUtils.getClientViewValidationState(model, view);
327 SimpleConstraint appliedSimpleConstraint = ConstraintStateUtils.getApplicableConstraint(
328 this.getSimpleConstraint(), validationState, stateMapping);
329
330 if (appliedSimpleConstraint != null
331 && appliedSimpleConstraint.getRequired() != null
332 && appliedSimpleConstraint.getRequired()) {
333 SimpleConstraint prevConstraint = ConstraintStateUtils.getApplicableConstraint(
334 this.getSimpleConstraint(), stateMapping.getCurrentState(stateObject), stateMapping);
335 if (prevConstraint == null || prevConstraint.getRequired() == null || !prevConstraint.getRequired()) {
336 this.getFieldLabel().getRequiredMessage().setMessageText("**");
337 }
338 }
339 }
340
341 ClientValidationUtils.processAndApplyConstraints(this, view, model);
342 }
343
344
345
346
347
348
349
350
351 protected void buildAutomaticQuickfinder(View view, Object model) {
352 QuickFinder autoQuickfinder = ComponentFactory.getQuickFinder();
353
354 view.getViewHelperService().spawnSubLifecyle(view, model, autoQuickfinder, this,
355 UifConstants.ViewPhases.INITIALIZE, UifConstants.ViewPhases.APPLY_MODEL);
356
357
358 if (autoQuickfinder.isRender()) {
359 this.quickfinder = autoQuickfinder;
360 }
361 }
362
363
364
365
366
367
368
369
370
371 @Override
372 protected void processReadOnlyListDisplay(Object model, List<?> originalList) {
373
374 if ((control != null) && control instanceof MultiValueControlBase) {
375 List<String> newList = new ArrayList<String>();
376 List<KeyValue> fieldOptions = ((MultiValueControlBase) control).getOptions();
377
378 if (fieldOptions == null || fieldOptions.isEmpty()) {
379 return;
380 }
381
382 for (Object fieldValue : originalList) {
383 for (KeyValue keyValue : fieldOptions) {
384 if (fieldValue != null && StringUtils.equals(fieldValue.toString(), keyValue.getKey())) {
385 newList.add(keyValue.getValue());
386 break;
387 }
388 }
389 }
390 this.setReadOnlyDisplayReplacement(super.generateReadOnlyListDisplayReplacement(newList));
391 } else {
392 this.setReadOnlyDisplayReplacement(super.generateReadOnlyListDisplayReplacement(originalList));
393 }
394 }
395
396
397
398
399
400
401
402 @Override
403 protected void setAlternateAndAdditionalDisplayValue(View view, Object model) {
404
405 if (StringUtils.isNotBlank(getReadOnlyDisplayReplacement()) || StringUtils.isNotBlank(
406 getReadOnlyDisplaySuffix())) {
407 return;
408 }
409
410 if (isApplyMask()) {
411 if ((this.quickfinder != null) && StringUtils.isNotBlank(this.quickfinder.getDataObjectClassName())) {
412 setWidgetInputOnly(true);
413 } else {
414 setReadOnly(true);
415 }
416 }
417
418 super.setAlternateAndAdditionalDisplayValue(view, model);
419 }
420
421
422
423
424
425
426 protected void adjustMustOccurConstraintBinding(List<MustOccurConstraint> mustOccurConstraints) {
427 if (mustOccurConstraints != null) {
428 for (MustOccurConstraint mustOccurConstraint : mustOccurConstraints) {
429 adjustPrerequisiteConstraintBinding(mustOccurConstraint.getPrerequisiteConstraints());
430 adjustMustOccurConstraintBinding(mustOccurConstraint.getMustOccurConstraints());
431 }
432 }
433 }
434
435
436
437
438
439
440 protected void adjustPrerequisiteConstraintBinding(List<PrerequisiteConstraint> prerequisiteConstraints) {
441 if (prerequisiteConstraints != null) {
442 for (PrerequisiteConstraint prerequisiteConstraint : prerequisiteConstraints) {
443 String propertyName = getBindingInfo().getPropertyAdjustedBindingPath(
444 prerequisiteConstraint.getPropertyName());
445 prerequisiteConstraint.setPropertyName(propertyName);
446 }
447 }
448 }
449
450
451
452
453
454
455 protected void setupFieldQuery() {
456 if (getAttributeQuery() != null) {
457
458 getAttributeQuery().updateQueryFieldMapping(getBindingInfo());
459 getAttributeQuery().updateReturnFieldMapping(getBindingInfo());
460 getAttributeQuery().updateQueryMethodArgumentFieldList(getBindingInfo());
461
462
463 String script = "executeFieldQuery('" + getControl().getId() + "',";
464 script += "'" + getId() + "'," + getAttributeQuery().getQueryFieldMappingJsString() + ",";
465 script += getAttributeQuery().getQueryMethodArgumentFieldsJsString() + ",";
466 script += getAttributeQuery().getReturnFieldMappingJsString() + ");";
467
468 if (StringUtils.isNotBlank(getControl().getOnBlurScript())) {
469 script = getControl().getOnBlurScript() + script;
470 }
471 getControl().setOnBlurScript(script);
472 }
473 }
474
475
476
477
478
479
480 protected void setupIds() {
481
482
483 setNestedComponentIdAndSuffix(getControl(), UifConstants.IdSuffixes.CONTROL);
484 setNestedComponentIdAndSuffix(getValidationMessages(), UifConstants.IdSuffixes.ERRORS);
485 setNestedComponentIdAndSuffix(getFieldLabel(), UifConstants.IdSuffixes.LABEL);
486 setNestedComponentIdAndSuffix(getInstructionalMessage(), UifConstants.IdSuffixes.INSTRUCTIONAL);
487 setNestedComponentIdAndSuffix(getConstraintMessage(), UifConstants.IdSuffixes.CONSTRAINT);
488 setNestedComponentIdAndSuffix(getQuickfinder(), UifConstants.IdSuffixes.QUICK_FINDER);
489 setNestedComponentIdAndSuffix(getSuggest(), UifConstants.IdSuffixes.SUGGEST);
490
491 if (this.getControl() != null) {
492 this.getControl().addDataAttribute(UifConstants.DataAttributes.CONTROL_FOR, this.getId());
493 }
494 }
495
496
497
498
499
500
501
502
503
504
505
506
507 @Override
508 public void copyFromAttributeDefinition(View view, AttributeDefinition attributeDefinition) {
509 super.copyFromAttributeDefinition(view, attributeDefinition);
510
511
512 if (getMaxLength() == null) {
513 setMaxLength(attributeDefinition.getMaxLength());
514 }
515
516
517 if (getMinLength() == null) {
518 setMinLength(attributeDefinition.getMinLength());
519 }
520
521
522 if (getValidCharactersConstraint() == null) {
523 setValidCharactersConstraint(attributeDefinition.getValidCharactersConstraint());
524 }
525
526 if (getCaseConstraint() == null) {
527 setCaseConstraint(attributeDefinition.getCaseConstraint());
528 }
529
530 if (getDependencyConstraints() == null) {
531 setDependencyConstraints(attributeDefinition.getPrerequisiteConstraints());
532 }
533
534 if (getMustOccurConstraints() == null) {
535 setMustOccurConstraints(attributeDefinition.getMustOccurConstraints());
536 }
537
538
539 if (getRequired() == null) {
540 setRequired(attributeDefinition.isRequired());
541
542
543 if (getRequired() == null) {
544 setRequired(Boolean.FALSE);
545 }
546 }
547
548 if (getDataType() == null) {
549 setDataType(attributeDefinition.getDataType());
550
551 if (getDataType() == null
552 && control instanceof TextControl
553 && ((TextControl) control).getDatePicker() != null) {
554 setDataType(DataType.DATE);
555 }
556 }
557
558
559 if ((getControl() == null) && (attributeDefinition.getControlField() != null)) {
560 Control control = attributeDefinition.getControlField();
561 view.assignComponentIds(control);
562
563 setControl(ComponentUtils.copy(control));
564 }
565
566
567 if (StringUtils.isEmpty(getConstraintText())) {
568 setConstraintText(attributeDefinition.getConstraintText());
569
570 if (constraintMessage == null) {
571 constraintMessage = ComponentFactory.getConstraintMessage();
572 view.assignComponentIds(constraintMessage);
573 }
574 getConstraintMessage().setMessageText(attributeDefinition.getConstraintText());
575 }
576
577
578 if (getOptionsFinder() == null) {
579 setOptionsFinder(attributeDefinition.getOptionsFinder());
580 }
581
582
583
584 if (this.getSimpleConstraint().getConstraintStateOverrides() == null) {
585 this.getSimpleConstraint().setConstraintStateOverrides(
586 attributeDefinition.getSimpleConstraint().getConstraintStateOverrides());
587 }
588
589 if (this.getSimpleConstraint().getStates().isEmpty()) {
590 this.getSimpleConstraint().setStates(attributeDefinition.getSimpleConstraint().getStates());
591 }
592
593 if (this.getSimpleConstraint().getMessageKey() == null) {
594 this.getSimpleConstraint().setMessageKey(attributeDefinition.getSimpleConstraint().getMessageKey());
595 }
596
597 if (this.getSimpleConstraint().getApplyClientSide() == null) {
598 this.getSimpleConstraint().setApplyClientSide(
599 attributeDefinition.getSimpleConstraint().getApplyClientSide());
600 }
601
602 if (this.getSimpleConstraint().getValidationMessageParams() == null) {
603 this.getSimpleConstraint().setValidationMessageParams(
604 attributeDefinition.getSimpleConstraint().getValidationMessageParams());
605 }
606 }
607
608
609
610
611 @Override
612 public List<Component> getComponentsForLifecycle() {
613 List<Component> components = super.getComponentsForLifecycle();
614
615 components.add(instructionalMessage);
616 components.add(constraintMessage);
617 components.add(control);
618 components.add(validationMessages);
619 components.add(quickfinder);
620 components.add(suggest);
621
622 return components;
623 }
624
625
626
627
628 @Override
629 public boolean isInputAllowed() {
630 return true;
631 }
632
633
634
635
636
637
638
639
640
641
642
643
644
645 @BeanTagAttribute(name = "control", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
646 public Control getControl() {
647 return this.control;
648 }
649
650
651
652
653
654
655 public void setControl(Control control) {
656 this.control = control;
657 }
658
659
660
661
662
663
664
665
666 @BeanTagAttribute(name = "validationMessages", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
667 public ValidationMessages getValidationMessages() {
668 return this.validationMessages;
669 }
670
671
672
673
674
675
676 public void setValidationMessages(ValidationMessages validationMessages) {
677 this.validationMessages = validationMessages;
678 }
679
680
681
682
683
684
685
686
687
688 @BeanTagAttribute(name = "optionsFinder", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
689 public KeyValuesFinder getOptionsFinder() {
690 return this.optionsFinder;
691 }
692
693
694
695
696
697
698 public void setOptionsFinder(KeyValuesFinder optionsFinder) {
699 this.optionsFinder = optionsFinder;
700 }
701
702
703
704
705
706
707 @BeanTagAttribute(name = "optionsFinderClass")
708 public Class<? extends KeyValuesFinder> getOptionsFinderClass(){
709 if(this.optionsFinder != null){
710 return this.optionsFinder.getClass();
711 }
712 else{
713 return null;
714 }
715 }
716
717
718
719
720
721
722
723 public void setOptionsFinderClass(Class<? extends KeyValuesFinder> optionsFinderClass) {
724 this.optionsFinder = ObjectUtils.newInstance(optionsFinderClass);
725 }
726
727
728
729
730
731
732
733
734
735
736
737
738 public boolean isEnableAutoDirectInquiry() {
739 return enableAutoDirectInquiry;
740 }
741
742
743
744
745
746
747 public void setEnableAutoDirectInquiry(boolean enableAutoDirectInquiry) {
748 this.enableAutoDirectInquiry = enableAutoDirectInquiry;
749 }
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765 @BeanTagAttribute(name = "quickfinder", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
766 public QuickFinder getQuickfinder() {
767 return this.quickfinder;
768 }
769
770
771
772
773
774
775 public void setQuickfinder(QuickFinder quickfinder) {
776 this.quickfinder = quickfinder;
777 }
778
779
780
781
782
783
784
785
786
787
788
789
790 public boolean isEnableAutoQuickfinder() {
791 return enableAutoQuickfinder;
792 }
793
794
795
796
797
798
799 public void setEnableAutoQuickfinder(boolean enableAutoQuickfinder) {
800 this.enableAutoQuickfinder = enableAutoQuickfinder;
801 }
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818 @BeanTagAttribute(name = "suggest", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
819 public Suggest getSuggest() {
820 return suggest;
821 }
822
823
824
825
826
827
828 public void setSuggest(Suggest suggest) {
829 this.suggest = suggest;
830 }
831
832
833
834
835
836
837
838
839
840 @BeanTagAttribute(name = "widgetInputOnly")
841 public boolean isWidgetInputOnly() {
842 return this.widgetInputOnly;
843 }
844
845
846
847
848
849
850 public void setWidgetInputOnly(boolean widgetInputOnly) {
851 this.widgetInputOnly = widgetInputOnly;
852 }
853
854
855
856
857
858
859
860
861
862
863
864 @BeanTagAttribute(name = "instructionalText")
865 public String getInstructionalText() {
866 return this.instructionalText;
867 }
868
869
870
871
872
873
874 public void setInstructionalText(String instructionalText) {
875 this.instructionalText = instructionalText;
876 }
877
878
879
880
881
882
883
884
885
886
887
888 @BeanTagAttribute(name = "instructionalMessage", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
889 public Message getInstructionalMessage() {
890 return this.instructionalMessage;
891 }
892
893
894
895
896
897
898
899
900
901
902
903 public void setInstructionalMessage(Message instructionalMessage) {
904 this.instructionalMessage = instructionalMessage;
905 }
906
907
908
909
910
911
912
913
914
915
916
917
918 @BeanTagAttribute(name = "constraintText")
919 public String getConstraintText() {
920 return this.constraintText;
921 }
922
923
924
925
926
927
928 public void setConstraintText(String constraintText) {
929 this.constraintText = constraintText;
930 }
931
932
933
934
935
936
937
938
939
940
941
942 @BeanTagAttribute(name = "constraintMessage", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
943 public Message getConstraintMessage() {
944 return this.constraintMessage;
945 }
946
947
948
949
950
951
952
953
954
955
956
957 public void setConstraintMessage(Message constraintMessage) {
958 this.constraintMessage = constraintMessage;
959 }
960
961
962
963
964
965
966 @Override
967 @BeanTagAttribute(name = "validCharactersConstraint", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
968 public ValidCharactersConstraint getValidCharactersConstraint() {
969 return this.validCharactersConstraint;
970 }
971
972
973
974
975
976
977 public void setValidCharactersConstraint(ValidCharactersConstraint validCharactersConstraint) {
978 this.validCharactersConstraint = validCharactersConstraint;
979 }
980
981
982
983
984
985
986 @Override
987 @BeanTagAttribute(name = "caseConstraint", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
988 public CaseConstraint getCaseConstraint() {
989 return this.caseConstraint;
990 }
991
992
993
994
995
996
997 public void setCaseConstraint(CaseConstraint caseConstraint) {
998 this.caseConstraint = caseConstraint;
999 }
1000
1001
1002
1003
1004
1005
1006 @BeanTagAttribute(name = "dependencyConstraints", type = BeanTagAttribute.AttributeType.LISTBEAN)
1007 public List<PrerequisiteConstraint> getDependencyConstraints() {
1008 return this.dependencyConstraints;
1009 }
1010
1011
1012
1013
1014
1015
1016 public void setDependencyConstraints(List<PrerequisiteConstraint> dependencyConstraints) {
1017 this.dependencyConstraints = dependencyConstraints;
1018 }
1019
1020 @Override
1021 public List<PrerequisiteConstraint> getPrerequisiteConstraints() {
1022 return dependencyConstraints;
1023 }
1024
1025
1026
1027
1028
1029
1030 @Override
1031 @BeanTagAttribute(name = "mustOccurConstraints", type = BeanTagAttribute.AttributeType.LISTBEAN)
1032 public List<MustOccurConstraint> getMustOccurConstraints() {
1033 return this.mustOccurConstraints;
1034 }
1035
1036
1037
1038
1039
1040
1041 public void setMustOccurConstraints(List<MustOccurConstraint> mustOccurConstraints) {
1042 this.mustOccurConstraints = mustOccurConstraints;
1043 }
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055 @Override
1056 @BeanTagAttribute(name = "simpleConstraint", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
1057 public SimpleConstraint getSimpleConstraint() {
1058 return this.simpleConstraint;
1059 }
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072 public void setSimpleConstraint(SimpleConstraint simpleConstraint) {
1073 this.simpleConstraint = simpleConstraint;
1074 }
1075
1076
1077
1078
1079
1080
1081
1082 public void setDataType(DataType dataType) {
1083 this.simpleConstraint.setDataType(dataType);
1084 }
1085
1086 public void setDataType(String dataType) {
1087 this.simpleConstraint.setDataType(DataType.valueOf(dataType));
1088 }
1089
1090
1091
1092
1093
1094
1095
1096
1097 @BeanTagAttribute(name = "dataType", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
1098 public DataType getDataType() {
1099 return this.simpleConstraint.getDataType();
1100 }
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115 @BeanTagAttribute(name = "maxLength")
1116 public Integer getMaxLength() {
1117 return simpleConstraint.getMaxLength();
1118 }
1119
1120
1121
1122
1123
1124
1125 public void setMaxLength(Integer maxLength) {
1126 simpleConstraint.setMaxLength(maxLength);
1127 }
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141 @BeanTagAttribute(name = "minLength")
1142 public Integer getMinLength() {
1143 return simpleConstraint.getMinLength();
1144 }
1145
1146
1147
1148
1149
1150
1151 public void setMinLength(Integer minLength) {
1152 simpleConstraint.setMinLength(minLength);
1153 }
1154
1155
1156
1157
1158 @Override
1159 @BeanTagAttribute(name = "required")
1160 public Boolean getRequired() {
1161 return this.simpleConstraint.getRequired();
1162 }
1163
1164
1165
1166
1167 @Override
1168 public void setRequired(Boolean required) {
1169 this.simpleConstraint.setRequired(required);
1170 }
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186 @BeanTagAttribute(name = "exclusiveMin")
1187 public String getExclusiveMin() {
1188 return simpleConstraint.getExclusiveMin();
1189 }
1190
1191
1192
1193
1194
1195
1196 public void setExclusiveMin(String exclusiveMin) {
1197 simpleConstraint.setExclusiveMin(exclusiveMin);
1198 }
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214 @BeanTagAttribute(name = "inclusiveMax")
1215 public String getInclusiveMax() {
1216 return simpleConstraint.getInclusiveMax();
1217 }
1218
1219
1220
1221
1222
1223
1224 public void setInclusiveMax(String inclusiveMax) {
1225 simpleConstraint.setInclusiveMax(inclusiveMax);
1226 }
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242 @BeanTagAttribute(name = "attributeQuery", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
1243 public AttributeQuery getAttributeQuery() {
1244 return attributeQuery;
1245 }
1246
1247
1248
1249
1250
1251
1252 public void setAttributeQuery(AttributeQuery attributeQuery) {
1253 this.attributeQuery = attributeQuery;
1254 }
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266 @BeanTagAttribute(name = "uppercaseValue")
1267 public boolean isUppercaseValue() {
1268 return uppercaseValue;
1269 }
1270
1271
1272
1273
1274
1275
1276 public void setUppercaseValue(boolean uppercaseValue) {
1277 this.uppercaseValue = uppercaseValue;
1278 }
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291 public boolean isDisableNativeAutocomplete() {
1292 return disableNativeAutocomplete;
1293 }
1294
1295
1296
1297
1298
1299
1300 public void setDisableNativeAutocomplete(boolean disableNativeAutocomplete) {
1301 this.disableNativeAutocomplete = disableNativeAutocomplete;
1302 }
1303
1304 @Override
1305 public boolean isRenderFieldset() {
1306 return super.isRenderFieldset() || (quickfinder != null
1307 && quickfinder.isRender()
1308 && quickfinder.getQuickfinderAction() != null
1309 && quickfinder.getQuickfinderAction().isRender());
1310 }
1311
1312
1313
1314
1315 @Override
1316 protected <T> void copyProperties(T component) {
1317 super.copyProperties(component);
1318
1319 InputField inputFieldCopy = (InputField) component;
1320
1321 inputFieldCopy.setCustomValidatorClass(this.customValidatorClass);
1322 inputFieldCopy.setValidCharactersConstraint(CloneUtils.deepClone(this.validCharactersConstraint));
1323 inputFieldCopy.setCaseConstraint(CloneUtils.deepClone(this.caseConstraint));
1324
1325 if (dependencyConstraints != null) {
1326 List<PrerequisiteConstraint> dependencyConstraintsCopy = Lists.newArrayListWithExpectedSize(
1327 dependencyConstraints.size());
1328
1329 for (PrerequisiteConstraint dependencyConstraint : dependencyConstraints) {
1330 dependencyConstraintsCopy.add(CloneUtils.deepClone(dependencyConstraint));
1331 }
1332
1333 inputFieldCopy.setDependencyConstraints(dependencyConstraintsCopy);
1334 }
1335
1336 if (mustOccurConstraints != null) {
1337 List<MustOccurConstraint> mustOccurConstraintsCopy = Lists.newArrayListWithExpectedSize(
1338 mustOccurConstraints.size());
1339
1340 for (MustOccurConstraint mustOccurConstraint : mustOccurConstraints) {
1341 mustOccurConstraintsCopy.add(CloneUtils.deepClone(mustOccurConstraint));
1342 }
1343
1344 inputFieldCopy.setMustOccurConstraints(mustOccurConstraintsCopy);
1345 }
1346
1347 inputFieldCopy.setSimpleConstraint(CloneUtils.deepClone(this.simpleConstraint));
1348 inputFieldCopy.setDataType(this.dataType);
1349
1350
1351 if (this.control != null) {
1352 inputFieldCopy.setControl((Control) this.control.copy());
1353 }
1354
1355 inputFieldCopy.setOptionsFinder(this.optionsFinder);
1356 inputFieldCopy.setUppercaseValue(this.uppercaseValue);
1357 inputFieldCopy.setDisableNativeAutocomplete(this.disableNativeAutocomplete);
1358
1359 if (this.validationMessages != null) {
1360 inputFieldCopy.setValidationMessages((ValidationMessages) this.validationMessages.copy());
1361 }
1362
1363
1364 inputFieldCopy.setConstraintText(this.constraintText);
1365 inputFieldCopy.setInstructionalText(this.instructionalText);
1366
1367 if (this.constraintMessage != null) {
1368 inputFieldCopy.setConstraintMessage((Message) this.constraintMessage.copy());
1369 }
1370
1371 if (this.instructionalMessage != null) {
1372 inputFieldCopy.setInstructionalMessage((Message) this.instructionalMessage.copy());
1373 }
1374
1375 if (this.attributeQuery != null) {
1376 inputFieldCopy.setAttributeQuery((AttributeQuery) this.attributeQuery.copy());
1377 }
1378
1379 inputFieldCopy.setEnableAutoDirectInquiry(this.enableAutoDirectInquiry);
1380
1381
1382 if (this.quickfinder != null) {
1383 inputFieldCopy.setQuickfinder((QuickFinder) this.quickfinder.copy());
1384 }
1385
1386 inputFieldCopy.setEnableAutoQuickfinder(this.enableAutoQuickfinder);
1387
1388 if (this.suggest != null) {
1389 inputFieldCopy.setSuggest((Suggest) this.suggest.copy());
1390 }
1391
1392 inputFieldCopy.setWidgetInputOnly(this.widgetInputOnly);
1393 }
1394
1395
1396
1397
1398 @Override
1399 public void completeValidation(ValidationTrace tracer) {
1400 tracer.addBean(this);
1401
1402
1403 if (getControl() == null) {
1404 if (Validator.checkExpressions(this, "control")) {
1405 String currentValues[] = {"control =" + getConstraintText()};
1406 tracer.createWarning("Control should be set", currentValues);
1407 }
1408 }
1409
1410 super.completeValidation(tracer.getCopy());
1411 }
1412
1413 public void setCustomValidatorClass(String customValidatorClass) {
1414 this.customValidatorClass = customValidatorClass;
1415 }
1416 }