001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.html5; 014 015import java.net.*; 016 017import org.apache.juneau.annotation.*; 018 019/** 020 * DTO for an HTML {@doc ExtHTML5.forms#the-input-element <input>} 021 * element. 022 * 023 * <ul class='seealso'> 024 * <li class='link'>{@doc DtoHtml5} 025 * </ul> 026 */ 027@Bean(typeName="input") 028public class Input extends HtmlElementVoid { 029 030 /** 031 * Creates an empty {@link Input} element. 032 */ 033 public Input() {} 034 035 /** 036 * Creates an {@link Input} element with the specified {@link Input#type(String)} attribute. 037 * 038 * @param type The {@link Input#type(String)} attribute. 039 */ 040 public Input(String type) { 041 type(type); 042 } 043 044 /** 045 * {@doc ExtHTML5.forms#attr-input-accept accept} attribute. 046 * 047 * <p> 048 * Hint for expected file type in file upload controls. 049 * 050 * @param accept The new value for this attribute. 051 * @return This object (for method chaining). 052 */ 053 public final Input accept(String accept) { 054 attr("accept", accept); 055 return this; 056 } 057 058 /** 059 * {@doc ExtHTML5.forms#attr-input-alt alt} attribute. 060 * 061 * <p> 062 * Replacement text for use when images are not available. 063 * 064 * @param alt The new value for this attribute. 065 * @return This object (for method chaining). 066 */ 067 public final Input alt(String alt) { 068 attr("alt", alt); 069 return this; 070 } 071 072 /** 073 * {@doc ExtHTML5.forms#attr-fe-autocomplete autocomplete} attribute. 074 * 075 * <p> 076 * Hint for form auto-fill feature. 077 * 078 * @param autocomplete The new value for this attribute. 079 * @return This object (for method chaining). 080 */ 081 public final Input autocomplete(String autocomplete) { 082 attr("autocomplete", autocomplete); 083 return this; 084 } 085 086 /** 087 * {@doc ExtHTML5.forms#attr-fe-autofocus autofocus} attribute. 088 * 089 * <p> 090 * Automatically focus the form control when the page is loaded. 091 * 092 * @param autofocus The new value for this attribute. 093 * @return This object (for method chaining). 094 */ 095 public final Input autofocus(String autofocus) { 096 attr("autofocus", autofocus); 097 return this; 098 } 099 100 /** 101 * {@doc ExtHTML5.forms#attr-input-checked checked} attribute. 102 * 103 * <p> 104 * Whether the command or control is checked. 105 * 106 * @param checked 107 * The new value for this attribute. 108 * Typically a {@link Boolean} or {@link String}. 109 * @return This object (for method chaining). 110 */ 111 public final Input checked(Object checked) { 112 attr("checked", deminimize(checked, "checked")); 113 return this; 114 } 115 116 /** 117 * {@doc ExtHTML5.forms#attr-fe-dirname dirname} attribute. 118 * 119 * <p> 120 * Name of form field to use for sending the element's directionality in form submission. 121 * 122 * @param dirname The new value for this attribute. 123 * @return This object (for method chaining). 124 */ 125 public final Input dirname(String dirname) { 126 attr("dirname", dirname); 127 return this; 128 } 129 130 /** 131 * {@doc ExtHTML5.forms#attr-fe-disabled disabled} attribute. 132 * 133 * <p> 134 * Whether the form control is disabled. 135 * 136 * @param disabled 137 * The new value for this attribute. 138 * Typically a {@link Boolean} or {@link String}. 139 * @return This object (for method chaining). 140 */ 141 public final Input disabled(Object disabled) { 142 attr("disabled", deminimize(disabled, "disabled")); 143 return this; 144 } 145 146 /** 147 * {@doc ExtHTML5.forms#attr-fae-form form} attribute. 148 * 149 * <p> 150 * Associates the control with a form element. 151 * 152 * @param form The new value for this attribute. 153 * @return This object (for method chaining). 154 */ 155 public final Input form(String form) { 156 attr("form", form); 157 return this; 158 } 159 160 /** 161 * {@doc ExtHTML5.forms#attr-fs-formaction formaction} attribute. 162 * 163 * <p> 164 * URL to use for form submission. 165 * 166 * @param formaction The new value for this attribute. 167 * @return This object (for method chaining). 168 */ 169 public final Input formaction(String formaction) { 170 attr("formaction", formaction); 171 return this; 172 } 173 174 /** 175 * {@doc ExtHTML5.forms#attr-fs-formenctype formenctype} attribute. 176 * 177 * <p> 178 * Form data set encoding type to use for form submission. 179 * 180 * @param formenctype The new value for this attribute. 181 * @return This object (for method chaining). 182 */ 183 public final Input formenctype(String formenctype) { 184 attr("formenctype", formenctype); 185 return this; 186 } 187 188 /** 189 * {@doc ExtHTML5.forms#attr-fs-formmethod formmethod} attribute. 190 * 191 * <p> 192 * HTTP method to use for form submission. 193 * 194 * @param formmethod The new value for this attribute. 195 * @return This object (for method chaining). 196 */ 197 public final Input formmethod(String formmethod) { 198 attr("formmethod", formmethod); 199 return this; 200 } 201 202 /** 203 * {@doc ExtHTML5.forms#attr-fs-formnovalidate formnovalidate} 204 * attribute. 205 * 206 * <p> 207 * Bypass form control validation for form submission. 208 * 209 * @param formnovalidate The new value for this attribute. 210 * @return This object (for method chaining). 211 */ 212 public final Input formnovalidate(String formnovalidate) { 213 attr("formnovalidate", formnovalidate); 214 return this; 215 } 216 217 /** 218 * {@doc ExtHTML5.forms#attr-fs-formtarget formtarget} attribute. 219 * 220 * <p> 221 * Browsing context for form submission. 222 * 223 * @param formtarget The new value for this attribute. 224 * @return This object (for method chaining). 225 */ 226 public final Input formtarget(String formtarget) { 227 attr("formtarget", formtarget); 228 return this; 229 } 230 231 /** 232 * {@doc ExtHTML5.embedded-content-0#attr-dim-height height} 233 * attribute. 234 * 235 * <p> 236 * Vertical dimension. 237 * 238 * @param height 239 * The new value for this attribute. 240 * Typically a {@link Number} or {@link String}. 241 * @return This object (for method chaining). 242 */ 243 public final Input height(Object height) { 244 attr("height", height); 245 return this; 246 } 247 248 /** 249 * {@doc ExtHTML5.embedded-content-0#attr-input-inputmode inputmode} 250 * attribute. 251 * Hint for selecting an input modality. 252 * 253 * @param inputmode The new value for this attribute. 254 * @return This object (for method chaining). 255 */ 256 public final Input inputmode(String inputmode) { 257 attr("inputmode", inputmode); 258 return this; 259 } 260 261 /** 262 * {@doc ExtHTML5.forms#attr-input-list list} attribute. 263 * 264 * <p> 265 * List of auto-complete options. 266 * 267 * @param list The new value for this attribute. 268 * @return This object (for method chaining). 269 */ 270 public final Input list(String list) { 271 attr("list", list); 272 return this; 273 } 274 275 /** 276 * {@doc ExtHTML5.forms#attr-input-max max} attribute. 277 * 278 * <p> 279 * Maximum value. 280 * 281 * @param max 282 * The new value for this attribute. 283 * Typically a {@link Number} or {@link String}. 284 * @return This object (for method chaining). 285 */ 286 public final Input max(Object max) { 287 attr("max", max); 288 return this; 289 } 290 291 /** 292 * {@doc ExtHTML5.forms#attr-input-maxlength maxlength} attribute. 293 * Maximum length of value. 294 * 295 * @param maxlength The new value for this attribute. 296 * Typically a {@link Number} or {@link String}. 297 * @return This object (for method chaining). 298 */ 299 public final Input maxlength(Object maxlength) { 300 attr("maxlength", maxlength); 301 return this; 302 } 303 304 /** 305 * {@doc ExtHTML5.forms#attr-input-min min} attribute. 306 * 307 * <p> 308 * Minimum value. 309 * 310 * @param min 311 * The new value for this attribute. 312 * Typically a {@link Number} or {@link String}. 313 * @return This object (for method chaining). 314 */ 315 public final Input min(Object min) { 316 attr("min", min); 317 return this; 318 } 319 320 /** 321 * {@doc ExtHTML5.forms#attr-input-minlength minlength} attribute. 322 * 323 * <p> 324 * Minimum length of value. 325 * 326 * @param minlength 327 * The new value for this attribute. 328 * Typically a {@link Number} or {@link String}. 329 * @return This object (for method chaining). 330 */ 331 public final Input minlength(Object minlength) { 332 attr("minlength", minlength); 333 return this; 334 } 335 336 /** 337 * {@doc ExtHTML5.forms#attr-input-multiple multiple} attribute. 338 * 339 * <p> 340 * Whether to allow multiple values. 341 * 342 * @param multiple 343 * The new value for this attribute. 344 * Typically a {@link Boolean} or {@link String}. 345 * @return This object (for method chaining). 346 */ 347 public final Input multiple(Object multiple) { 348 attr("multiple", deminimize(multiple, "multiple")); 349 return this; 350 } 351 352 /** 353 * {@doc ExtHTML5.forms#attr-fe-name name} attribute. 354 * 355 * <p> 356 * Name of form control to use for form submission and in the form.elements API. 357 * 358 * @param name The new value for this attribute. 359 * @return This object (for method chaining). 360 */ 361 public final Input name(String name) { 362 attr("name", name); 363 return this; 364 } 365 366 /** 367 * {@doc ExtHTML5.forms#attr-input-pattern pattern} attribute. 368 * 369 * <p> 370 * Pattern to be matched by the form control's value. 371 * 372 * @param pattern The new value for this attribute. 373 * @return This object (for method chaining). 374 */ 375 public final Input pattern(String pattern) { 376 attr("pattern", pattern); 377 return this; 378 } 379 380 /** 381 * {@doc ExtHTML5.forms#attr-input-placeholder placeholder} attribute. 382 * 383 * <p> 384 * User-visible label to be placed within the form control. 385 * 386 * @param placeholder The new value for this attribute. 387 * @return This object (for method chaining). 388 */ 389 public final Input placeholder(String placeholder) { 390 attr("placeholder", placeholder); 391 return this; 392 } 393 394 /** 395 * {@doc ExtHTML5.forms#attr-input-readonly readonly} attribute. 396 * 397 * <p> 398 * Whether to allow the value to be edited by the user. 399 * 400 * @param readonly 401 * The new value for this attribute. 402 * Typically a {@link Boolean} or {@link String}. 403 * @return This object (for method chaining). 404 */ 405 public final Input readonly(Object readonly) { 406 attr("readonly", readonly); 407 return this; 408 } 409 410 411 /** 412 * {@doc ExtHTML5.forms#attr-input-readonly readonly} attribute. 413 * 414 * <p> 415 * Whether to allow the value to be edited by the user. 416 * 417 * @param readonly If <jk>true</jk>, adds <c>readonly="readonly"</c>. 418 * @return This object (for method chaining). 419 */ 420 public final Input readonly(boolean readonly) { 421 if (readonly) 422 readonly("readonly"); 423 return this; 424 } 425 426 /** 427 * {@doc ExtHTML5.forms#attr-input-readonly required} attribute. 428 * 429 * <p> 430 * Whether the control is required for form submission. 431 * 432 * @param required 433 * The new value for this attribute. 434 * Typically a {@link Boolean} or {@link String}. 435 * @return This object (for method chaining). 436 */ 437 public final Input required(Object required) { 438 attr("required", required); 439 return this; 440 } 441 442 /** 443 * {@doc ExtHTML5.forms#attr-input-size size} attribute. 444 * 445 * <p> 446 * Size of the control. 447 * 448 * @param size 449 * The new value for this attribute. 450 * Typically a {@link Number} or {@link String}. 451 * @return This object (for method chaining). 452 */ 453 public final Input size(Object size) { 454 attr("size", size); 455 return this; 456 } 457 458 /** 459 * {@doc ExtHTML5.forms#attr-input-src src} attribute. 460 * 461 * <p> 462 * Address of the resource. 463 * 464 * @param src 465 * The new value for this attribute. 466 * Typically a {@link URL} or {@link String}. 467 * @return This object (for method chaining). 468 */ 469 public final Input src(Object src) { 470 attr("src", src); 471 return this; 472 } 473 474 /** 475 * {@doc ExtHTML5.forms#attr-input-step step} attribute. 476 * 477 * <p> 478 * Granularity to be matched by the form control's value. 479 * 480 * @param step The new value for this attribute. 481 * @return This object (for method chaining). 482 */ 483 public final Input step(String step) { 484 attr("step", step); 485 return this; 486 } 487 488 /** 489 * {@doc ExtHTML5.forms#attr-input-type type} attribute. 490 * 491 * <p> 492 * Type of form control. 493 * 494 * @param type The new value for this attribute. 495 * @return This object (for method chaining). 496 */ 497 public final Input type(String type) { 498 attr("type", type); 499 return this; 500 } 501 502 /** 503 * {@doc ExtHTML5.forms#attr-input-value value} attribute. 504 * 505 * <p> 506 * Value of the form control. 507 * 508 * @param value 509 * The new value for this attribute. 510 * Typically a {@link Number} or {@link String}. 511 * @return This object (for method chaining). 512 */ 513 public final Input value(Object value) { 514 attr("value", value); 515 return this; 516 } 517 518 /** 519 * {@doc ExtHTML5.embedded-content-0#attr-dim-width width} attribute. 520 * 521 * <p> 522 * Horizontal dimension. 523 * 524 * @param width 525 * The new value for this attribute. 526 * Typically a {@link Number} or {@link String}. 527 * @return This object (for method chaining). 528 */ 529 public final Input width(Object width) { 530 attr("width", width); 531 return this; 532 } 533 534 535 //----------------------------------------------------------------------------------------------------------------- 536 // Overridden methods 537 //----------------------------------------------------------------------------------------------------------------- 538 539 @Override /* HtmlElement */ 540 public final Input _class(String _class) { 541 super._class(_class); 542 return this; 543 } 544 545 @Override /* HtmlElement */ 546 public final Input id(String id) { 547 super.id(id); 548 return this; 549 } 550 551 @Override /* HtmlElement */ 552 public final Input style(String style) { 553 super.style(style); 554 return this; 555 } 556}