1 /** 2 * Copyright 2005-2016 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.util.List; 19 20 import org.kuali.rice.core.api.data.DataType; 21 import org.kuali.rice.krad.datadictionary.validation.capability.CaseConstrainable; 22 import org.kuali.rice.krad.datadictionary.validation.capability.MustOccurConstrainable; 23 import org.kuali.rice.krad.datadictionary.validation.capability.PrerequisiteConstrainable; 24 import org.kuali.rice.krad.datadictionary.validation.capability.SimpleConstrainable; 25 import org.kuali.rice.krad.datadictionary.validation.capability.ValidCharactersConstrainable; 26 import org.kuali.rice.krad.datadictionary.validation.constraint.CaseConstraint; 27 import org.kuali.rice.krad.datadictionary.validation.constraint.MustOccurConstraint; 28 import org.kuali.rice.krad.datadictionary.validation.constraint.PrerequisiteConstraint; 29 import org.kuali.rice.krad.datadictionary.validation.constraint.SimpleConstraint; 30 import org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint; 31 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace; 32 import org.kuali.rice.krad.keyvalues.KeyValuesFinder; 33 import org.kuali.rice.krad.uif.component.Component; 34 import org.kuali.rice.krad.uif.control.Control; 35 import org.kuali.rice.krad.uif.element.FieldValidationMessages; 36 import org.kuali.rice.krad.uif.element.Message; 37 import org.kuali.rice.krad.uif.element.ValidationMessages; 38 import org.kuali.rice.krad.uif.widget.QuickFinder; 39 import org.kuali.rice.krad.uif.widget.Suggest; 40 41 /** 42 * TODO mark don't forget to fill this in. 43 * 44 * @author Kuali Rice Team (rice.collab@kuali.org) 45 */ 46 public interface InputField extends SimpleConstrainable, CaseConstrainable, PrerequisiteConstrainable, MustOccurConstrainable, ValidCharactersConstrainable, DataField { 47 48 /** 49 * @see DataField#isInputAllowed() 50 */ 51 boolean isInputAllowed(); 52 53 /** 54 * {@code Control} instance that should be used to input data for the 55 * field 56 * 57 * <p> 58 * When the field is editable, the control will be rendered so the user can 59 * input a value(s). Controls typically are part of a Form and render 60 * standard HTML control elements such as text input, select, and checkbox 61 * </p> 62 * 63 * @return Control instance 64 */ 65 Control getControl(); 66 67 /** 68 * Setter for the field's control 69 * 70 * @param control 71 */ 72 void setControl(Control control); 73 74 /** 75 * When inlineEdit is enabled, the field will appear as text, and when clicked the user will be able to edit that 76 * field's value and save that new value. 77 * 78 * <p>The method that is called by inlineEdit is saveField.</p> 79 * 80 * @return inlineEdit if set to true the field will have the ability to be edited inline 81 */ 82 public boolean isInlineEdit(); 83 84 /** 85 * @see org.kuali.rice.krad.uif.field.InputFieldBase#isInlineEdit() 86 */ 87 public void setInlineEdit(boolean inlineEdit); 88 89 /** 90 * When ajaxInlineEdit is enabled, the field will appear as text, and when clicked, the input version of that field 91 * is retrieved from the server; the user will be able to edit that field's value and save that new value. 92 * 93 * @return ajaxInlneEdit if true the field will have the ability to be edited inline via ajax call 94 */ 95 public boolean isAjaxInlineEdit(); 96 97 /** 98 * @see InputFieldBase#isAjaxInlineEdit() 99 */ 100 public void setAjaxInlineEdit(boolean ajaxInlineEdit); 101 102 /** 103 * Field that contains the messages (errors) for the input field. The 104 * {@code ValidationMessages} holds configuration on associated messages along 105 * with information on rendering the messages in the user interface 106 * 107 * @return ValidationMessages instance 108 */ 109 FieldValidationMessages getValidationMessages(); 110 111 /** 112 * Setter for the input field's errors field 113 * 114 * @param validationMessages 115 */ 116 void setValidationMessages(FieldValidationMessages validationMessages); 117 118 /** 119 * Instance of {@code KeyValuesFinder} that should be invoked to 120 * provide a List of values the field can have. Generally used to provide 121 * the options for a multi-value control or to validate the submitted field 122 * value 123 * 124 * @return KeyValuesFinder instance 125 */ 126 KeyValuesFinder getOptionsFinder(); 127 128 /** 129 * Setter for the field's KeyValuesFinder instance 130 * 131 * @param optionsFinder 132 */ 133 void setOptionsFinder(KeyValuesFinder optionsFinder); 134 135 /** 136 * Get the class of the optionsFinder being used by this InputField 137 * 138 * @return the class of the set optionsFinder, if not set or not applicable, returns null 139 */ 140 Class<? extends KeyValuesFinder> getOptionsFinderClass(); 141 142 /** 143 * Setter that takes in the class name for the options finder and creates a 144 * new instance to use as the finder for the input field 145 * 146 * @param optionsFinderClass the options finder class to set 147 */ 148 void setOptionsFinderClass(Class<? extends KeyValuesFinder> optionsFinderClass); 149 150 /** 151 * Indicates whether direct inquiries should be automatically set when a relationship for 152 * the field's property is found 153 * 154 * <p> 155 * Note this only applies when the {@link #getInquiry()} widget has not been configured (is null) 156 * and is set to true by default 157 * </p> 158 * 159 * @return true if auto direct inquiries are enabled, false if not 160 */ 161 boolean isEnableAutoDirectInquiry(); 162 163 /** 164 * Setter for enabling automatic direct inquiries 165 * 166 * @param enableAutoDirectInquiry 167 */ 168 void setEnableAutoDirectInquiry(boolean enableAutoDirectInquiry); 169 170 /** 171 * Lookup finder widget for the field 172 * 173 * <p> 174 * The quickfinder widget places a small icon next to the field that allows 175 * the user to bring up a search screen for finding valid field values. The 176 * {@code Widget} instance can be configured to point to a certain 177 * {@code LookupView}, or the framework will attempt to associate the 178 * field with a lookup based on its metadata (in particular its 179 * relationships in the model) 180 * </p> 181 * 182 * @return QuickFinder lookup widget 183 */ 184 QuickFinder getQuickfinder(); 185 186 /** 187 * Setter for the lookup widget 188 * 189 * @param quickfinder the field lookup widget to set 190 */ 191 void setQuickfinder(QuickFinder quickfinder); 192 193 /** 194 * Indicates whether quickfinders should be automatically set when a relationship for the field's 195 * property is found 196 * 197 * <p> 198 * Note this only applies when the {@link #getQuickfinder()} widget has not been configured (is null) 199 * and is set to true by default 200 * </p> 201 * 202 * @return true if auto quickfinders are enabled, false if not 203 */ 204 boolean isEnableAutoQuickfinder(); 205 206 /** 207 * Setter for enabling automatic quickfinders 208 * 209 * @param enableAutoQuickfinder 210 */ 211 void setEnableAutoQuickfinder(boolean enableAutoQuickfinder); 212 213 /** 214 * Suggest box widget for the input field 215 * 216 * <p> 217 * If enabled (by render flag), as the user inputs data into the 218 * fields control a dynamic query is performed to provide the user 219 * suggestions on values which they can then select 220 * </p> 221 * 222 * <p> 223 * Note the Suggest widget is only valid when using a standard TextControl 224 * </p> 225 * 226 * @return Suggest instance 227 */ 228 Suggest getSuggest(); 229 230 /** 231 * Setter for the fields suggest widget 232 * 233 * @param suggest the field suggest widget to set 234 */ 235 void setSuggest(Suggest suggest); 236 237 /** 238 * Indicates indicates whether the field can only be updated through a widget 239 * 240 * widgetInputOnly behaves similar to ReadOnly with the exception that the value of the input field 241 * can be changed via the associated widget (e.g. spinner, date picker, quickfinder, etc). 242 * 243 * @return true if only widget input is allowed, false otherwise 244 */ 245 boolean isWidgetInputOnly(); 246 247 /** 248 * Setter for the widget input only indicator 249 * 250 * @param widgetInputOnly 251 */ 252 void setWidgetInputOnly(boolean widgetInputOnly); 253 254 /** 255 * Forces rendering of the input group div around the control. 256 * 257 * <p>If other components add content through script that should be grouped with the control, this flag 258 * can be set to true to generate the input group, even though {@link InputField#getPostInputAddons()} may 259 * be empty</p> 260 * 261 * @return boolean true to force rendering of the input group, false if not 262 */ 263 boolean isRenderInputAddonGroup(); 264 265 /** 266 * @see InputField#isRenderInputAddonGroup() 267 */ 268 void setRenderInputAddonGroup(boolean renderInputAddonGroup); 269 270 /** 271 * List of CSS classes that will be applied to the span that wraps the post input components. 272 * 273 * TODO: revisist this, possibly getting the classes from component wrapper css classes once created 274 * 275 * @return List of CSS classes 276 */ 277 List<String> getPostInputCssClasses(); 278 279 /** 280 * Returns the list of post input css classes as a string formed by joining the classes with a space. 281 * 282 * @return post input css classes string 283 */ 284 String getPostInputCssClassesAsString(); 285 286 /** 287 * @see InputField#getPostInputCssClasses() 288 */ 289 void setPostInputCssClasses(List<String> postInputCssClasses); 290 291 /** 292 * List of components that will be grouped with the input field control to form an input group. 293 * 294 * <p>Generally these are icon, link, or button components that should be rendered with the control.</p> 295 * 296 * <p>See <a href="http://getbootstrap.com/components/#input-groups">Bootstrap Input Groups</a></p> 297 * 298 * @return List of post input components 299 */ 300 List<Component> getPostInputAddons(); 301 302 /** 303 * @see org.kuali.rice.krad.uif.field.InputField#getPostInputAddons() 304 */ 305 void setPostInputAddons(List<Component> postInputAddons); 306 307 /** 308 * Adds a component to the list of post input addon components. 309 * 310 * @param addOn component to add 311 * @see InputField#getPostInputAddons() 312 */ 313 void addPostInputAddon(Component addOn); 314 315 /** 316 * Instructional text that display an explanation of the field usage 317 * 318 * <p> 319 * Text explaining how to use the field, including things like what values should be selected 320 * in certain cases and so on (instructions) 321 * </p> 322 * 323 * @return instructional message 324 */ 325 String getInstructionalText(); 326 327 /** 328 * Setter for the instructional message 329 * 330 * @param instructionalText the instructional text to set 331 */ 332 void setInstructionalText(String instructionalText); 333 334 /** 335 * Message field that displays instructional text 336 * 337 * <p> 338 * This message field can be configured to for adjusting how the instructional text will display. Generally 339 * the styleClasses property will be of most interest 340 * </p> 341 * 342 * @return instructional message field 343 */ 344 Message getInstructionalMessage(); 345 346 /** 347 * Setter for the instructional text message field 348 * 349 * <p> 350 * Note this is the setter for the field that will render the instructional text. The actual text can be 351 * set on the field but can also be set using {@link #setInstructionalText(String)} 352 * </p> 353 * 354 * @param instructionalMessage the instructional message to set 355 */ 356 void setInstructionalMessage(Message instructionalMessage); 357 358 /** 359 * Help text that displays under the control and is disclosed on focus. 360 * 361 * @return String help text for input 362 */ 363 String getHelperText(); 364 365 /** 366 * @see InputField#getHelperText() 367 */ 368 void setHelperText(String helperText); 369 370 /** 371 * Text that display a restriction on the value a field can hold 372 * 373 * <p> 374 * For example when the value must be a valid format (phone number, email), certain length, min/max value and 375 * so on this text can be used to indicate the constraint to the user. Generally displays with the control so 376 * it is visible when the user tabs to the field 377 * </p> 378 * 379 * @return text to display for the constraint message 380 */ 381 String getConstraintText(); 382 383 /** 384 * Setter for the constraint message text 385 * 386 * @param constraintText the constraint text to set 387 */ 388 void setConstraintText(String constraintText); 389 390 /** 391 * Message field that displays constraint text 392 * 393 * <p> 394 * This message field can be configured to for adjusting how the constrain text will display. Generally 395 * the styleClasses property will be of most interest 396 * </p> 397 * 398 * @return constraint message field 399 */ 400 Message getConstraintMessage(); 401 402 /** 403 * Setter for the constraint text message field 404 * 405 * <p> 406 * Note this is the setter for the field that will render the constraint text. The actual text can be 407 * set on the field but can also be set using {@link #setConstraintText(String)} 408 * </p> 409 * 410 * @param constraintMessage the constrain message field to set 411 */ 412 void setConstraintMessage(Message constraintMessage); 413 414 /** 415 * Setter for {@code validCharacterConstraint} 416 * 417 * @param validCharactersConstraint the {@code ValidCharactersConstraint} to set 418 */ 419 void setValidCharactersConstraint(ValidCharactersConstraint validCharactersConstraint); 420 421 /** 422 * Setter for {@code caseConstraint} 423 * 424 * @param caseConstraint the {@code CaseConstraint} to set 425 */ 426 void setCaseConstraint(CaseConstraint caseConstraint); 427 428 /** 429 * List of {@code PrerequisiteConstraint} that apply to this {@code InputField} 430 * 431 * @return the dependency constraints for this input field 432 */ 433 List<PrerequisiteConstraint> getDependencyConstraints(); 434 435 /** 436 * Setter for {@code dependencyConstraints} 437 * 438 * @param dependencyConstraints list of {@code PrerequisiteConstraint} to set 439 */ 440 void setDependencyConstraints(List<PrerequisiteConstraint> dependencyConstraints); 441 442 /** 443 * Setter for {@code mustOccurConstraints} 444 * 445 * @param mustOccurConstraints list of {@code MustOccurConstraint} to set 446 */ 447 void setMustOccurConstraints(List<MustOccurConstraint> mustOccurConstraints); 448 449 /** 450 * Setter for simple constraint 451 * 452 * <p> 453 * When a simple constraint is set on this object ALL simple validation 454 * constraints set directly will be overridden - recommended to use this or 455 * the other gets/sets for defining simple constraints, not both. 456 * </p> 457 * 458 * @param simpleConstraint the simple constraint to set 459 */ 460 void setSimpleConstraint(SimpleConstraint simpleConstraint); 461 462 /** 463 * This does not have to be set, represents the DataType constraint of this field. 464 * This is only checked during server side validation. 465 * 466 * @param dataType the dataType to set 467 */ 468 void setDataType(DataType dataType); 469 470 void setDataType(String dataType); 471 472 /** 473 * Gets the DataType of this InputField, note that DataType set to be date 474 * when this field is using a date picker with a TextControl and has not otherwise been 475 * explicitly set. 476 * 477 * @return DataType 478 */ 479 DataType getDataType(); 480 481 /** 482 * Maximum number of characters the input field value is allowed to have 483 * 484 * <p> 485 * The maximum length determines the maximum allowable length of the value 486 * for data entry editing purposes. The maximum length is inclusive and can 487 * be smaller or longer than the actual control size. The constraint 488 * is enforced on all data types (e.g. a numeric data type needs to meet the 489 * maximum length constraint in which digits and symbols are counted). 490 * </p> 491 * 492 * @return the maximum length of the input field 493 */ 494 Integer getMaxLength(); 495 496 /** 497 * Setter for input field max length 498 * 499 * @param maxLength the maximum length to set 500 */ 501 void setMaxLength(Integer maxLength); 502 503 /** 504 * Minimum number of characters the input field value needs to be 505 * 506 * <p> 507 * The minimum length determines the minimum required length of the value for 508 * data entry editing purposes. The minimum length is inclusive. The constraint 509 * is enforced on all data types (e.g. a numeric data type needs to meet the 510 * minimum length requirement in which digits and symbols are counted). 511 * </p> 512 * 513 * @return the minimum length of the input field 514 */ 515 Integer getMinLength(); 516 517 /** 518 * Setter for input field minimum length 519 * 520 * @param minLength the minLength to set 521 */ 522 void setMinLength(Integer minLength); 523 524 /** 525 * @see org.kuali.rice.krad.uif.component.ComponentBase#getRequired() 526 */ 527 Boolean getRequired(); 528 529 /** 530 * @see org.kuali.rice.krad.uif.component.ComponentBase#setRequired(java.lang.Boolean) 531 */ 532 void setRequired(Boolean required); 533 534 /** 535 * The exclusive minimum value for numeric or date field. 536 * 537 * <p> 538 * The exclusiveMin element determines the minimum allowable value for data 539 * entry editing purposes. This constrain is supported for numeric and 540 * date fields and to be used in conjunction with the appropriate 541 * {@link ValidCharactersConstraint}. 542 * 543 * For numeric constraint the value can be an integer or decimal such as -.001 or 99. 544 * </p> 545 * 546 * @return the exclusive minimum numeric value of the input field 547 */ 548 String getExclusiveMin(); 549 550 /** 551 * Setter for the field's exclusive minimum value 552 * 553 * @param exclusiveMin the minimum value to set 554 */ 555 void setExclusiveMin(String exclusiveMin); 556 557 /** 558 * The inclusive maximum value for numeric or date field. 559 * 560 * <p> 561 * The inclusiveMax element determines the maximum allowable value for data 562 * entry editing purposes. This constrain is supported for numeric and 563 * date fields and to be used in conjunction with the appropriate 564 * {@link ValidCharactersConstraint}. 565 * 566 * For numeric constraint the value can be an integer or decimal such as -.001 or 99. 567 * </p> 568 * 569 * @return the inclusive maximum numeric value of the input field 570 */ 571 String getInclusiveMax(); 572 573 /** 574 * Setter for the field's inclusive maximum value 575 * 576 * @param inclusiveMax the maximum value to set 577 */ 578 void setInclusiveMax(String inclusiveMax); 579 580 /** 581 * Attribute query instance configured for this field to dynamically pull information back for 582 * updates other fields or providing messages 583 * 584 * <p> 585 * If field attribute query is not null, associated event script will be generated to trigger the 586 * query from the UI. This will invoke the {@code AttributeQueryService} to 587 * execute the query and return an instance of {@code AttributeQueryResult} that is then 588 * read by the script to update the UI. Typically used to update informational property values or 589 * other field values 590 * </p> 591 * 592 * @return AttributeQuery instance 593 */ 594 AttributeQuery getAttributeQuery(); 595 596 /** 597 * Setter for this field's attribute query 598 * 599 * @param attributeQuery 600 */ 601 void setAttributeQuery(AttributeQuery attributeQuery); 602 603 /** 604 * Perform uppercase flag for this field to force input to uppercase. 605 * 606 * <p> 607 * It this flag is set to true the 'text-transform' style on the field will be set to 'uppercase' 608 * which will automatically change any text input into the field to uppercase. 609 * </p> 610 * 611 * @return performUppercase flag 612 */ 613 boolean isUppercaseValue(); 614 615 /** 616 * Setter for this field's performUppercase flag 617 * 618 * @param uppercaseValue boolean flag 619 */ 620 void setUppercaseValue(boolean uppercaseValue); 621 622 /** 623 * Indicates whether the browser autocomplete functionality should be disabled for the 624 * input field (adds autocomplete="off") 625 * 626 * <p> 627 * The browser's native autocomplete functionality can cause issues with security fields and also fields 628 * with the UIF suggest widget enabled 629 * </p> 630 * 631 * @return true if the native autocomplete should be turned off for the input field, false if not 632 */ 633 boolean isDisableNativeAutocomplete(); 634 635 /** 636 * Setter to disable browser autocomplete for the input field 637 * 638 * @param disableNativeAutocomplete 639 */ 640 void setDisableNativeAutocomplete(boolean disableNativeAutocomplete); 641 642 boolean isRenderFieldset(); 643 644 /** 645 * @see org.kuali.rice.krad.uif.component.Component#completeValidation 646 */ 647 void completeValidation(ValidationTrace tracer); 648 649 }