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 org.apache.juneau.annotation.*;
016
017/**
018 * DTO for an HTML {@doc ExtHTML5.forms#the-textarea-element <textarea>}
019 * element.
020 *
021 * <ul class='seealso'>
022 *    <li class='link'>{@doc DtoHtml5}
023 * </ul>
024 */
025@Bean(typeName="textarea")
026public class Textarea extends HtmlElementRawText {
027
028   /**
029    * Creates an empty {@link Textarea} element.
030    */
031   public Textarea() {}
032
033   /**
034    * Creates a {@link Textarea} element with the specified {@link Textarea#name(String)} attribute and
035    * {@link Textarea#text(Object)} node.
036    *
037    * @param name The {@link Textarea#name(String)} attribute.
038    * @param text The {@link Textarea#text(Object)} node.
039    */
040   public Textarea(String name, String text) {
041      name(name).text(text);
042   }
043
044   /**
045    * {@doc ExtHTML5.forms#attr-fe-autocomplete autocomplete} attribute.
046    *
047    * <p>
048    * Hint for form auto-fill feature.
049    *
050    * @param autocomplete The new value for this attribute.
051    * @return This object (for method chaining).
052    */
053   public final Textarea autocomplete(String autocomplete) {
054      attr("autocomplete", autocomplete);
055      return this;
056   }
057
058   /**
059    * {@doc ExtHTML5.forms#attr-fe-autofocus autofocus} attribute.
060    *
061    * <p>
062    * Automatically focus the form control when the page is loaded.
063    *
064    * @param autofocus
065    *    The new value for this attribute.
066    *    Typically a {@link Boolean} or {@link String}.
067    * @return This object (for method chaining).
068    */
069   public final Textarea autofocus(Boolean autofocus) {
070      attr("autofocus", autofocus);
071      return this;
072   }
073
074   /**
075    * {@doc ExtHTML5.forms#attr-textarea-cols cols} attribute.
076    *
077    * <p>
078    * Maximum number of characters per line.
079    *
080    * @param cols
081    *    The new value for this attribute.
082    *    Typically a {@link Number} or {@link String}.
083    * @return This object (for method chaining).
084    */
085   public final Textarea cols(Object cols) {
086      attr("cols", cols);
087      return this;
088   }
089
090   /**
091    * {@doc ExtHTML5.forms#attr-fe-dirname dirname} attribute.
092    *
093    * <p>
094    * Name of form field to use for sending the element's directionality in form submission.
095    *
096    * @param dirname The new value for this attribute.
097    * @return This object (for method chaining).
098    */
099   public final Textarea dirname(String dirname) {
100      attr("dirname", dirname);
101      return this;
102   }
103
104   /**
105    * {@doc ExtHTML5.forms#attr-fe-disabled disabled} attribute.
106    *
107    * <p>
108    * Whether the form control is disabled.
109    *
110    * @param disabled
111    *    The new value for this attribute.
112    *    Typically a {@link Boolean} or {@link String}.
113    * @return This object (for method chaining).
114    */
115   public final Textarea disabled(Object disabled) {
116      attr("disabled", deminimize(disabled, "disabled"));
117      return this;
118   }
119
120   /**
121    * {@doc ExtHTML5.forms#attr-fae-form form} attribute.
122    *
123    * <p>
124    * Associates the control with a form element.
125    *
126    * @param form The new value for this attribute.
127    * @return This object (for method chaining).
128    */
129   public final Textarea form(String form) {
130      attr("form", form);
131      return this;
132   }
133
134   /**
135    * {@doc ExtHTML5.forms#inputmode inputmode} attribute.
136    *
137    * <p>
138    * Hint for selecting an input modality.
139    *
140    * @param inputmode The new value for this attribute.
141    * @return This object (for method chaining).
142    */
143   public final Textarea inputmode(String inputmode) {
144      attr("inputmode", inputmode);
145      return this;
146   }
147
148   /**
149    * {@doc ExtHTML5.forms#attr-textarea-maxlength maxlength} attribute.
150    *
151    * <p>
152    * Maximum length of value.
153    *
154    * @param maxlength
155    *    The new value for this attribute.
156    *    Typically a {@link Number} or {@link String}.
157    * @return This object (for method chaining).
158    */
159   public final Textarea maxlength(Object maxlength) {
160      attr("maxlength", maxlength);
161      return this;
162   }
163
164   /**
165    * {@doc ExtHTML5.forms#attr-textarea-minlength minlength} attribute.
166    *
167    * <p>
168    * Minimum length of value.
169    *
170    * @param minlength
171    *    The new value for this attribute.
172    *    Typically a {@link Number} or {@link String}.
173    * @return This object (for method chaining).
174    */
175   public final Textarea minlength(Object minlength) {
176      attr("minlength", minlength);
177      return this;
178   }
179
180   /**
181    * {@doc ExtHTML5.forms#attr-fe-name name} attribute.
182    *
183    * <p>
184    * Name of form control to use for form submission and in the form.elements API.
185    *
186    * @param name The new value for this attribute.
187    * @return This object (for method chaining).
188    */
189   public final Textarea name(String name) {
190      attr("name", name);
191      return this;
192   }
193
194   /**
195    * {@doc ExtHTML5.forms#attr-textarea-placeholder placeholder}
196    * attribute.
197    *
198    * <p>
199    * User-visible label to be placed within the form control.
200    *
201    * @param placeholder The new value for this attribute.
202    * @return This object (for method chaining).
203    */
204   public final Textarea placeholder(String placeholder) {
205      attr("placeholder", placeholder);
206      return this;
207   }
208
209   /**
210    * {@doc ExtHTML5.forms#attr-textarea-readonly readonly} attribute.
211    *
212    * <p>
213    * Whether to allow the value to be edited by the user.
214    *
215    * @param readonly
216    *    The new value for this attribute.
217    *    Typically a {@link Boolean} or {@link String}.
218    * @return This object (for method chaining).
219    */
220   public final Textarea readonly(Object readonly) {
221      attr("readonly", readonly);
222      return this;
223   }
224
225   /**
226    * {@doc ExtHTML5.forms#attr-textarea-required required} attribute.
227    *
228    * <p>
229    * Whether the control is required for form submission.
230    *
231    * @param required
232    *    The new value for this attribute.
233    *    Typically a {@link Boolean} or {@link String}.
234    * @return This object (for method chaining).
235    */
236   public final Textarea required(Object required) {
237      attr("required", required);
238      return this;
239   }
240
241   /**
242    * {@doc ExtHTML5.forms#attr-textarea-rows rows} attribute.
243    *
244    * <p>
245    * Number of lines to show.
246    *
247    * @param rows
248    *    The new value for this attribute.
249    *    Typically a {@link Number} or {@link String}.
250    * @return This object (for method chaining).
251    */
252   public final Textarea rows(Number rows) {
253      attr("rows", rows);
254      return this;
255   }
256
257   /**
258    * {@doc ExtHTML5.forms#attr-textarea-wrap wrap} attribute.
259    *
260    * <p>
261    * How the value of the form control is to be wrapped for form submission.
262    *
263    * @param wrap The new value for this attribute.
264    * @return This object (for method chaining).
265    */
266   public final Textarea wrap(String wrap) {
267      attr("wrap", wrap);
268      return this;
269   }
270
271
272   //-----------------------------------------------------------------------------------------------------------------
273   // Overridden methods
274   //-----------------------------------------------------------------------------------------------------------------
275
276   @Override /* HtmlElement */
277   public final Textarea _class(String _class) {
278      super._class(_class);
279      return this;
280   }
281
282   @Override /* HtmlElement */
283   public final Textarea id(String id) {
284      super.id(id);
285      return this;
286   }
287
288   @Override /* HtmlElement */
289   public final Textarea style(String style) {
290      super.style(style);
291      return this;
292   }
293
294   @Override /* HtmlElementText */
295   public Textarea text(Object text) {
296      super.text(text);
297      return this;
298   }
299}