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