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