1 /**
2 * Copyright 2005-2014 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krad.uif.field;
17
18 import java.beans.PropertyEditor;
19 import java.util.List;
20
21 import org.kuali.rice.krad.datadictionary.AttributeDefinition;
22 import org.kuali.rice.krad.datadictionary.mask.MaskFormatter;
23 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
24 import org.kuali.rice.krad.uif.component.ComponentSecurity;
25 import org.kuali.rice.krad.uif.component.DataBinding;
26 import org.kuali.rice.krad.uif.widget.Helpable;
27 import org.kuali.rice.krad.uif.widget.Inquiry;
28 import org.kuali.rice.krad.valuefinder.ValueFinder;
29
30 /**
31 * Component interface for data fields.
32 *
33 * @author Kuali Rice Team (rice.collab@kuali.org)
34 */
35 public interface DataField extends DataBinding, Helpable, Field {
36
37 /**
38 * Defaults the properties of the <code>DataField</code> to the
39 * corresponding properties of its <code>AttributeDefinition</code>
40 * retrieved from the dictionary (if such an entry exists). If the field
41 * already contains a value for a property, the definitions value is not
42 * used.
43 *
44 * @param attributeDefinition AttributeDefinition instance the property values should be
45 * copied from
46 */
47 void copyFromAttributeDefinition(AttributeDefinition attributeDefinition);
48
49 /**
50 * Indicates whether the data field instance allows input, subclasses should override and set to
51 * true if input is allowed
52 *
53 * @return true if input is allowed, false if read only
54 */
55 boolean isInputAllowed();
56
57 /**
58 * Setter for the component's property name
59 *
60 * @param propertyName
61 */
62 void setPropertyName(String propertyName);
63
64 /**
65 * Performs formatting of the field value for display and then converting the value back to its
66 * expected type from a string
67 *
68 * <p>
69 * Note property editors exist and are already registered for the basic Java types and the
70 * common Kuali types such as [@link KualiDecimal}. Registration with this property is only
71 * needed for custom property editors
72 * </p>
73 *
74 * @return PropertyEditor property editor instance to use for this field
75 */
76 PropertyEditor getPropertyEditor();
77
78 /**
79 * Setter for the custom property editor to use for the field
80 *
81 * @param propertyEditor
82 */
83 void setPropertyEditor(PropertyEditor propertyEditor);
84
85 /**
86 * Convenience setter for configuring a property editor by class
87 *
88 * @param propertyEditorClass
89 */
90 void setPropertyEditorClass(Class<? extends PropertyEditor> propertyEditorClass);
91
92 /**
93 * Returns the full binding path (the path used in the name attribute of the input).
94 * This differs from propertyName in that it uses BindingInfo to determine the path.
95 *
96 * @return full binding path name
97 */
98 String getName();
99
100 /**
101 * Name of the attribute within the data dictionary the attribute field is
102 * associated with
103 *
104 * <p>
105 * During the initialize phase for the <code>View</code>, properties for
106 * attribute fields are defaulted from a corresponding
107 * <code>AttributeDefinition</code> in the data dictionary. Based on the
108 * propertyName and parent object class the framework attempts will
109 * determine the attribute definition that is associated with the field and
110 * set this property. However this property can also be set in the fields
111 * configuration to use another dictionary attribute.
112 * </p>
113 *
114 * <p>
115 * The attribute name is used along with the dictionary object entry to find
116 * the <code>AttributeDefinition</code>
117 * </p>
118 *
119 * @return attribute name
120 */
121 String getDictionaryAttributeName();
122
123 /**
124 * Setter for the dictionary attribute name
125 *
126 * @param dictionaryAttributeName
127 */
128 void setDictionaryAttributeName(String dictionaryAttributeName);
129
130 /**
131 * Object entry name in the data dictionary the associated attribute is
132 * apart of
133 *
134 * <p>
135 * During the initialize phase for the <code>View</code>, properties for
136 * attribute fields are defaulted from a corresponding
137 * <code>AttributeDefinition</code> in the data dictionary. Based on the
138 * parent object class the framework will determine the object entry for the
139 * associated attribute. However the object entry can be set in the field's
140 * configuration to use another object entry for the attribute
141 * </p>
142 *
143 * <p>
144 * The attribute name is used along with the dictionary object entry to find
145 * the <code>AttributeDefinition</code>
146 * </p>
147 *
148 * @return String
149 */
150 String getDictionaryObjectEntry();
151
152 /**
153 * Setter for the dictionary object entry
154 *
155 * @param dictionaryObjectEntry
156 */
157 void setDictionaryObjectEntry(String dictionaryObjectEntry);
158
159 /**
160 * Default value for the model property the field points to
161 *
162 * <p>
163 * When a new <code>View</code> instance is requested, the corresponding
164 * model will be newly created. During this initialization process the value
165 * for the model property will be set to the given default value, if it was null.
166 * This will only work on properties which can be determined to be null.
167 * Therefore a String property with an empty string value will
168 * not be ovewritten with the defaultValue set here.
169 * </p>
170 *
171 * <p>
172 * In addition, int, boolean, and other primitive types
173 * will not use this default value because they inherently have a value in Java (0 for int, false for boolean, etc).
174 * To use such types either using a primitive wrapper type (Integer, Boolean, etc) so an unset variable can
175 * be determined to be null, or explicitly set the default value on the form/object itself for these types and
176 * not through this property.
177 * </p>
178 *
179 * @return default value
180 */
181 Object getDefaultValue();
182
183 /**
184 * Setter for the fields default value
185 *
186 * @param defaultValue
187 */
188 void setDefaultValue(Object defaultValue);
189
190 /**
191 * Gives Class that should be invoked to produce the default value for the
192 * field
193 *
194 * @return default value finder class
195 */
196 Class<? extends ValueFinder> getDefaultValueFinderClass();
197
198 /**
199 * Setter for the default value finder class
200 *
201 * @param defaultValueFinderClass
202 */
203 void setDefaultValueFinderClass(Class<? extends ValueFinder> defaultValueFinderClass);
204
205 /**
206 * Array of default values for the model property the field points to
207 *
208 * <p>
209 * When a new <code>View</code> instance is requested, the corresponding
210 * model will be newly created. During this initialization process the value
211 * for the model property will be set to the given default values (if set)
212 * </p>
213 *
214 * @return default value
215 */
216 Object[] getDefaultValues();
217
218 /**
219 * Setter for the fields default values
220 *
221 * @param defaultValues
222 */
223 void setDefaultValues(Object[] defaultValues);
224
225 String getForcedValue();
226
227 void setForcedValue(String forcedValue);
228
229 /**
230 * Summary help text for the field
231 *
232 * @return summary help text
233 */
234 String getHelpSummary();
235
236 /**
237 * Setter for the summary help text
238 *
239 * @param helpSummary
240 */
241 void setHelpSummary(String helpSummary);
242
243 /**
244 * Data Field Security object that indicates what authorization (permissions) exist for the field
245 *
246 * @return DataFieldSecurity instance
247 */
248 DataFieldSecurity getDataFieldSecurity();
249
250 /**
251 * Override to assert a {@link DataFieldSecurity} instance is set
252 *
253 * @param componentSecurity instance of DataFieldSecurity
254 */
255 void setComponentSecurity(ComponentSecurity componentSecurity);
256
257 /**
258 * Indicates the field should be read-only but also a hidden should be generated for the field
259 *
260 * <p>
261 * Useful for when a value is just displayed but is needed by script
262 * </p>
263 *
264 * @return true if field should be readOnly hidden, false if not
265 */
266 boolean isAddHiddenWhenReadOnly();
267
268 /**
269 * Setter for the read-only hidden indicator
270 *
271 * @param addHiddenWhenReadOnly
272 */
273 void setAddHiddenWhenReadOnly(boolean addHiddenWhenReadOnly);
274
275 /**
276 * Inquiry widget for the field
277 *
278 * <p>
279 * The inquiry widget will render a link for the field value when read-only
280 * that points to the associated inquiry view for the field. The inquiry can
281 * be configured to point to a certain <code>InquiryView</code>, or the
282 * framework will attempt to associate the field with a inquiry based on its
283 * metadata (in particular its relationships in the model)
284 * </p>
285 *
286 * @return Inquiry field inquiry
287 */
288 Inquiry getInquiry();
289
290 /**
291 * Setter for the inquiry widget
292 *
293 * @param inquiry
294 */
295 void setInquiry(Inquiry inquiry);
296
297 /**
298 * Indicates whether inquiries should be automatically set when a relationship for the field's property
299 * is found
300 *
301 * <p>
302 * Note this only applies when the {@link #getInquiry()} widget has not been configured (is null)
303 * and is set to true by default
304 * </p>
305 *
306 * @return true if auto inquiries are enabled, false if not
307 */
308 boolean isEnableAutoInquiry();
309
310 /**
311 * Setter for enabling automatic inquiries
312 *
313 * @param enableAutoInquiry
314 */
315 void setEnableAutoInquiry(boolean enableAutoInquiry);
316
317 /**
318 * When true, render the info message span which contains can contain additional information
319 * about the field (used by Field Query functionality)
320 *
321 * @return true if the span will be rendered, false otherwise
322 */
323 boolean isRenderInfoMessageSpan();
324
325 /**
326 * @see org.kuali.rice.krad.uif.field.DataField#isRenderInfoMessageSpan()
327 * @param renderInfoMessageSpan
328 */
329 void setRenderInfoMessageSpan(boolean renderInfoMessageSpan);
330
331 /**
332 * When true, render the marker icon span to show icons related to the field (used by CompareFieldCreateModifier on
333 * maintenance documetnts to mark editted fields)
334 *
335 * @return true if the the marker icon span will be rendered, false otherwise
336 */
337 boolean isRenderMarkerIconSpan();
338
339 /**
340 * @see org.kuali.rice.krad.uif.field.DataField#isRenderMarkerIconSpan()
341 * @param renderMarkerIconSpan
342 */
343 void setRenderMarkerIconSpan(boolean renderMarkerIconSpan);
344
345 /**
346 * Additional display attribute name, which will be displayed next to the actual field value
347 * when the field is readonly with hyphen in between like PropertyValue - AdditionalPropertyValue
348 *
349 * @param readOnlyDisplaySuffixPropertyName name of the additional display property
350 */
351 void setReadOnlyDisplaySuffixPropertyName(String readOnlyDisplaySuffixPropertyName);
352
353 /**
354 * Returns the additional display attribute name to be displayed when the field is readonly
355 *
356 * @return additional display attribute name
357 */
358 String getReadOnlyDisplaySuffixPropertyName();
359
360 /**
361 * Sets the alternate display attribute name to be displayed when the field is readonly.
362 * This properties value will be displayed instead of actual fields value when the field is readonly.
363 *
364 * @param readOnlyDisplayReplacementPropertyName alternate display property name
365 */
366 void setReadOnlyDisplayReplacementPropertyName(String readOnlyDisplayReplacementPropertyName);
367
368 /**
369 * Returns the alternate display attribute name to be displayed when the field is readonly.
370 *
371 * @return alternate Display Property Name
372 */
373 String getReadOnlyDisplayReplacementPropertyName();
374
375 /**
376 * Returns the alternate display value
377 *
378 * @return the alternate display value set for this field
379 */
380 String getReadOnlyDisplayReplacement();
381
382 /**
383 * Setter for the alternative display value
384 *
385 * @param value
386 */
387 void setReadOnlyDisplayReplacement(String value);
388
389 /**
390 * Returns the additional display value.
391 *
392 * @return the additional display value set for this field
393 */
394 String getReadOnlyDisplaySuffix();
395
396 /**
397 * Setter for the additional display value
398 *
399 * @param value
400 */
401 void setReadOnlyDisplaySuffix(String value);
402
403 /**
404 * Gets the readOnlyListDisplayType.
405 *
406 * <p>When this is not set, the list will default to the delimited list display with a default of comma and space
407 * (", ") - if readOnlyListDelimiter is not set as well. The type can be set as the following:
408 * <ul>
409 * <li>"DELIMITED" - list will be output with delimiters between each item defined by readOnlyListDelimiter</li>
410 * <li>"BREAK" - list will be output with breaks between each item</li>
411 * <li>"OL" - list will be output in ordered list format (numbered)</li>
412 * <li>"UL" - list will be output in unordered list format (bulleted)</li>
413 * </ul>
414 * </p>
415 *
416 * @return the display type to use
417 */
418 String getReadOnlyListDisplayType();
419
420 /**
421 * Set the readOnlyListDisplayType
422 *
423 * @param readOnlyListDisplayType
424 */
425 void setReadOnlyListDisplayType(String readOnlyListDisplayType);
426
427 /**
428 * The readOnlyListDelimiter is used to set the delimiter used when "DELIMITED" type is set for
429 * readOnlyListDisplayType
430 *
431 * @return the delimiter to use in readOnly list output with "DELIMITED" type set
432 */
433 String getReadOnlyListDelimiter();
434
435 /**
436 * Set the readOnlyListDelimiter
437 *
438 * @param readOnlyListDelimiter
439 */
440 void setReadOnlyListDelimiter(String readOnlyListDelimiter);
441
442 /**
443 * Indicates whether the value for the field should be masked (or partially masked) on display
444 *
445 * <p>
446 * If set to true, the field value will be masked by applying the configured {@link #getMaskFormatter()}
447 * </p>
448 *
449 * <p>
450 * If a KIM permission exists that should be checked to determine whether the value should be masked or not,
451 * this value should not be set but instead the mask or partialMask property on {@link #getComponentSecurity()}
452 * should be set to true. This indicates there is a mask permission that should be consulted. If the user
453 * does not have the permission, this flag will be set to true by the framework and the value masked using
454 * the mask formatter configured on the security object
455 * </p>
456 *
457 * @return true if the field value should be masked, false if not
458 */
459 boolean isApplyMask();
460
461 /**
462 * Setter for the apply value mask flag
463 *
464 * @param applyMask
465 */
466 void setApplyMask(boolean applyMask);
467
468 /**
469 * MaskFormatter instance that will be used to mask the field value when {@link #isApplyMask()} is true
470 *
471 * <p>
472 * Note in cases where the mask is applied due to security (KIM permissions), the mask or partial mask formatter
473 * configured on {@link #getComponentSecurity()} will be used instead of this mask formatter
474 * </p>
475 *
476 * @return MaskFormatter instance
477 */
478 MaskFormatter getMaskFormatter();
479
480 /**
481 * Setter for the MaskFormatter instance to apply when the value is masked
482 *
483 * @param maskFormatter
484 */
485 void setMaskFormatter(MaskFormatter maskFormatter);
486
487 /**
488 * Allows specifying hidden property names without having to specify as a
489 * field in the group config (that might impact layout)
490 *
491 * @return hidden property names
492 */
493 List<String> getAdditionalHiddenPropertyNames();
494
495 /**
496 * Setter for the hidden property names
497 *
498 * @param additionalHiddenPropertyNames
499 */
500 void setAdditionalHiddenPropertyNames(List<String> additionalHiddenPropertyNames);
501
502 /**
503 * List of property names whose values should be displayed read-only under this field
504 *
505 * <p>
506 * In the attribute field template for each information property name given its values is
507 * outputted read-only. Informational property values can also be updated dynamically with
508 * the use of field attribute query
509 * </p>
510 *
511 * <p>
512 * Simple property names can be given if the property has the same binding parent as this
513 * field, in which case the binding path will be adjusted by the framework. If the property
514 * names starts with org.kuali.rice.krad.uif.UifConstants#NO_BIND_ADJUST_PREFIX, no binding
515 * prefix will be added.
516 * </p>
517 *
518 * @return informational property names
519 */
520 List<String> getPropertyNamesForAdditionalDisplay();
521
522 /**
523 * Setter for the list of informational property names
524 *
525 * @param propertyNamesForAdditionalDisplay
526 */
527 void setPropertyNamesForAdditionalDisplay(List<String> propertyNamesForAdditionalDisplay);
528
529 /**
530 * Sets HTML escaping for this property value. HTML escaping will be handled in alternate and additional fields
531 * also.
532 */
533 void setEscapeHtmlInPropertyValue(boolean escapeHtmlInPropertyValue);
534
535 /**
536 * Returns true if HTML escape allowed for this field
537 *
538 * @return true if escaping allowed
539 */
540 boolean isEscapeHtmlInPropertyValue();
541
542 /**
543 * Returns true if this field is of type {@code TextAreaControl}.
544 *
545 * <p>
546 * Used to preserve text formatting in a textarea when the view
547 * is readOnly by enclosing the text in a </pre> tag.
548 * </p>
549 *
550 * @return true if the field is of type {@code TextAreaControl}
551 */
552 boolean isMultiLineReadOnlyDisplay();
553
554 /**
555 * Setter for multiLineReadOnlyDisplay
556 *
557 * @param multiLineReadOnlyDisplay
558 */
559 void setMultiLineReadOnlyDisplay(boolean multiLineReadOnlyDisplay);
560
561 /**
562 * Indicates whether the value for the field is secure.
563 *
564 * <p>
565 * A value will be secured if masking has been applied (by configuration or a failed KIM permission) or the field
566 * has been marked as hidden due to a required KIM permission check failing.
567 * </p>
568 *
569 * @return true if value is secure, false if not
570 */
571 boolean hasSecureValue();
572
573 boolean isRenderFieldset();
574
575 /**
576 * @see org.kuali.rice.krad.uif.component.Component#completeValidation
577 */
578 void completeValidation(ValidationTrace tracer);
579
580 }