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