001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bean.html5;
018
019import org.apache.juneau.annotation.*;
020import org.apache.juneau.internal.*;
021
022/**
023 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#the-textarea-element">&lt;textarea&gt;</a>
024 * element.
025 *
026 * <p>
027 * The textarea element represents a multiline text input control. It allows users to enter and edit
028 * text over multiple lines, making it suitable for longer text content such as comments, descriptions,
029 * or messages. The textarea element supports various attributes for controlling its size, behavior,
030 * and validation.
031 *
032 * <h5 class='section'>Examples:</h5>
033 * <p class='bcode w800'>
034 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
035 * 
036 *    <jc>// Basic textarea</jc>
037 *    Textarea <jv>basic</jv> = <jsm>textarea</jsm>(<js>"comments"</js>)
038 *       .rows(4)
039 *       .cols(50);
040 * 
041 *    <jc>// Textarea with placeholder and validation</jc>
042 *    Textarea <jv>validated</jv> = <jsm>textarea</jsm>(<js>"description"</js>)
043 *       .placeholder(<js>"Enter a description..."</js>)
044 *       .required(<jk>true</jk>)
045 *       .minlength(10)
046 *       .maxlength(500);
047 * 
048 *    <jc>// Textarea with initial content</jc>
049 *    Textarea <jv>withContent</jv> = <jsm>textarea</jsm>(<js>"message"</js>)
050 *       .text(<js>"Default message text"</js>);
051 * 
052 *    <jc>// Textarea with styling and behavior</jc>
053 *    Textarea <jv>styled</jv> = <jsm>textarea</jsm>(<js>"feedback"</js>)
054 *       ._class(<js>"large-textarea"</js>)
055 *       .rows(6)
056 *       .cols(60)
057 *       .placeholder(<js>"Please provide your feedback..."</js>)
058 *       .wrap(<js>"hard"</js>);
059 * 
060 *    <jc>// Disabled textarea</jc>
061 *    Textarea <jv>disabled</jv> = <jsm>textarea</jsm>(<js>"readonly"</js>)
062 *       .disabled(true)
063 *       .text("This textarea is disabled");
064 * 
065 *    // Textarea with form association
066 *    Textarea external = new Textarea()
067 *       .name="external"
068 *       .form="myForm"
069 *       .placeholder="This textarea is outside the form";
070 * </p>
071 *
072 * <p>
073 * The following convenience methods are provided for constructing instances of this bean:
074 * <ul class='javatree'>
075 *    <li class='jc'>{@link HtmlBuilder}
076 *    <ul class='javatree'>
077 *       <li class='jm'>{@link HtmlBuilder#textarea() textarea()}
078 *       <li class='jm'>{@link HtmlBuilder#textarea(Object, Object...) textarea(Object, Object...)}
079 *    </ul>
080 * </ul>
081 * </p>
082 *
083 * <h5 class='section'>See Also:</h5><ul>
084 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
085 * </ul>
086 */
087@Bean(typeName="textarea")
088public class Textarea extends HtmlElementRawText {
089
090   /**
091    * Creates an empty {@link Textarea} element.
092    */
093   public Textarea() {}
094
095   /**
096    * Creates a {@link Textarea} element with the specified {@link Textarea#name(String)} attribute and
097    * {@link Textarea#text(Object)} node.
098    *
099    * @param name The {@link Textarea#name(String)} attribute.
100    * @param text The {@link Textarea#text(Object)} node.
101    */
102   public Textarea(String name, String text) {
103      name(name).text(text);
104   }
105
106   /**
107    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-autocomplete">autocomplete</a> attribute.
108    *
109    * <p>
110    * Specifies whether the browser should automatically complete the form field based on user's previous input.
111    *
112    * <p>
113    * Possible values:
114    * <ul>
115    *    <li><js>"on"</js> - Allow autocomplete (default)</li>
116    *    <li><js>"off"</js> - Disable autocomplete</li>
117    *    <li><js>"name"</js> - Autocomplete for name fields</li>
118    *    <li><js>"email"</js> - Autocomplete for email fields</li>
119    *    <li><js>"username"</js> - Autocomplete for username fields</li>
120    *    <li><js>"current-password"</js> - Autocomplete for current password</li>
121    *    <li><js>"new-password"</js> - Autocomplete for new password</li>
122    * </ul>
123    *
124    * @param autocomplete Autocomplete behavior for the form field.
125    * @return This object.
126    */
127   public Textarea autocomplete(String value) {
128      attr("autocomplete", value);
129      return this;
130   }
131
132   /**
133    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus">autofocus</a> attribute.
134    *
135    * <p>
136    * Automatically focus the form control when the page is loaded.
137    *
138    * @param autofocus
139    *    The new value for this attribute.
140    *    Typically a {@link Boolean} or {@link String}.
141    * @return This object.
142    */
143   public Textarea autofocus(Object value) {
144      attr("autofocus", value);
145      return this;
146   }
147
148   /**
149    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-cols">cols</a> attribute.
150    *
151    * <p>
152    * Specifies the visible width of the textarea in characters. This is a hint for the browser
153    * and may not be exactly followed depending on the font and styling.
154    *
155    * @param cols The visible width of the textarea in characters.
156    * @return This object.
157    */
158   public Textarea cols(Object value) {
159      attr("cols", value);
160      return this;
161   }
162
163   /**
164    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-dirname">dirname</a> attribute.
165    *
166    * <p>
167    * Specifies the name of a hidden form field that will be submitted along with the textarea value,
168    * containing the text direction (ltr or rtl) of the textarea content.
169    *
170    * <p>
171    * This is useful for forms that need to preserve text direction information when submitted.
172    * The hidden field will contain either "ltr" or "rtl" based on the textarea's direction.
173    *
174    * @param dirname The name of the hidden field for directionality information.
175    * @return This object.
176    */
177   public Textarea dirname(String value) {
178      attr("dirname", value);
179      return this;
180   }
181
182   /**
183    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-disabled">disabled</a> attribute.
184    *
185    * <p>
186    * Whether the form control is disabled.
187    *
188    * <p>
189    * This attribute uses deminimized values:
190    * <ul>
191    *    <li><jk>false</jk> - Attribute is not added</li>
192    *    <li><jk>true</jk> - Attribute is added as <js>"disabled"</js></li>
193    *    <li>Other values - Passed through as-is</li>
194    * </ul>
195    *
196    * @param disabled
197    *    The new value for this attribute.
198    *    Typically a {@link Boolean} or {@link String}.
199    * @return This object.
200    */
201   public Textarea disabled(Object value) {
202      attr("disabled", deminimize(value, "disabled"));
203      return this;
204   }
205
206   /**
207    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute.
208    *
209    * <p>
210    * Associates the textarea with a form element by specifying the form's ID. This allows the textarea
211    * to be placed outside the form element while still being part of the form submission.
212    *
213    * <p>
214    * The value should match the ID of a form element in the same document.
215    *
216    * @param form The ID of the form element to associate with this textarea.
217    * @return This object.
218    */
219   public Textarea form(String value) {
220      attr("form", value);
221      return this;
222   }
223
224   /**
225    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#inputmode">inputmode</a> attribute.
226    *
227    * <p>
228    * Provides a hint to browsers about the type of virtual keyboard to display on mobile devices.
229    *
230    * <p>
231    * Possible values:
232    * <ul>
233    *    <li><js>"none"</js> - No virtual keyboard</li>
234    *    <li><js>"text"</js> - Standard text keyboard (default)</li>
235    *    <li><js>"tel"</js> - Telephone number keyboard</li>
236    *    <li><js>"url"</js> - URL keyboard with .com key</li>
237    *    <li><js>"email"</js> - Email keyboard with @ key</li>
238    *    <li><js>"numeric"</js> - Numeric keyboard</li>
239    *    <li><js>"decimal"</js> - Decimal number keyboard</li>
240    *    <li><js>"search"</js> - Search keyboard</li>
241    * </ul>
242    *
243    * @param inputmode The type of virtual keyboard to display.
244    * @return This object.
245    */
246   public Textarea inputmode(String value) {
247      attr("inputmode", value);
248      return this;
249   }
250
251   /**
252    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-maxlength">maxlength</a> attribute.
253    *
254    * <p>
255    * Maximum length of value.
256    *
257    * @param maxlength
258    *    The new value for this attribute.
259    *    Typically a {@link Number} or {@link String}.
260    * @return This object.
261    */
262   public Textarea maxlength(Object value) {
263      attr("maxlength", value);
264      return this;
265   }
266
267   /**
268    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-minlength">minlength</a> attribute.
269    *
270    * <p>
271    * Minimum length of value.
272    *
273    * @param minlength
274    *    The new value for this attribute.
275    *    Typically a {@link Number} or {@link String}.
276    * @return This object.
277    */
278   public Textarea minlength(Object value) {
279      attr("minlength", value);
280      return this;
281   }
282
283   /**
284    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-name">name</a> attribute.
285    *
286    * <p>
287    * Specifies the name of the form control. This name is used when the form is submitted and
288    * can be used to access the element via the form.elements API.
289    *
290    * <p>
291    * The name should be unique within the form and should not contain spaces or special characters.
292    *
293    * @param name The name of the form control for submission and API access.
294    * @return This object.
295    */
296   public Textarea name(String value) {
297      attr("name", value);
298      return this;
299   }
300
301   /**
302    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-placeholder">placeholder</a>
303    * attribute.
304    *
305    * <p>
306    * Provides a hint to the user about what to enter in the textarea. The placeholder text is displayed
307    * when the textarea is empty and disappears when the user starts typing.
308    *
309    * <p>
310    * The placeholder should be a brief, helpful description of the expected input.
311    *
312    * @param placeholder The placeholder text to display when the textarea is empty.
313    * @return This object.
314    */
315   public Textarea placeholder(String value) {
316      attr("placeholder", value);
317      return this;
318   }
319
320   /**
321    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-readonly">readonly</a> attribute.
322    *
323    * <p>
324    * Whether to allow the value to be edited by the user.
325    *
326    * @param readonly
327    *    The new value for this attribute.
328    *    Typically a {@link Boolean} or {@link String}.
329    * @return This object.
330    */
331   public Textarea readonly(Object value) {
332      attr("readonly", value);
333      return this;
334   }
335
336   /**
337    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-required">required</a> attribute.
338    *
339    * <p>
340    * Whether the control is required for form submission.
341    *
342    * @param required
343    *    The new value for this attribute.
344    *    Typically a {@link Boolean} or {@link String}.
345    * @return This object.
346    */
347   public Textarea required(Object value) {
348      attr("required", value);
349      return this;
350   }
351
352   /**
353    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-rows">rows</a> attribute.
354    *
355    * <p>
356    * Specifies the visible height of the textarea in lines. This is a hint for the browser
357    * and may not be exactly followed depending on the font and styling.
358    *
359    * @param rows The visible height of the textarea in lines.
360    * @return This object.
361    */
362   public Textarea rows(Number value) {
363      attr("rows", value);
364      return this;
365   }
366
367   /**
368    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-textarea-wrap">wrap</a> attribute.
369    *
370    * <p>
371    * Specifies how the text in the textarea should be wrapped when the form is submitted.
372    *
373    * <p>
374    * Possible values:
375    * <ul>
376    *    <li><js>"soft"</js> - Text is wrapped in the display but not in the submitted value (default)</li>
377    *    <li><js>"hard"</js> - Text is wrapped in both display and submitted value</li>
378    *    <li><js>"off"</js> - Text is not wrapped</li>
379    * </ul>
380    *
381    * @param wrap How the text should be wrapped for form submission.
382    * @return This object.
383    */
384   public Textarea wrap(String value) {
385      attr("wrap", value);
386      return this;
387   }
388
389   //-----------------------------------------------------------------------------------------------------------------
390   // Overridden methods
391   //-----------------------------------------------------------------------------------------------------------------
392   @Override /* Overridden from HtmlElement */
393   public Textarea _class(String value) {  // NOSONAR - Intentional naming.
394      super._class(value);
395      return this;
396   }
397
398   @Override /* Overridden from HtmlElement */
399   public Textarea accesskey(String value) {
400      super.accesskey(value);
401      return this;
402   }
403
404   @Override /* Overridden from HtmlElement */
405   public Textarea contenteditable(Object value) {
406      super.contenteditable(value);
407      return this;
408   }
409
410   @Override /* Overridden from HtmlElement */
411   public Textarea dir(String value) {
412      super.dir(value);
413      return this;
414   }
415
416   @Override /* Overridden from HtmlElement */
417   public Textarea hidden(Object value) {
418      super.hidden(value);
419      return this;
420   }
421
422   @Override /* Overridden from HtmlElement */
423   public Textarea id(String value) {
424      super.id(value);
425      return this;
426   }
427
428   @Override /* Overridden from HtmlElement */
429   public Textarea lang(String value) {
430      super.lang(value);
431      return this;
432   }
433
434   @Override /* Overridden from HtmlElement */
435   public Textarea onabort(String value) {
436      super.onabort(value);
437      return this;
438   }
439
440   @Override /* Overridden from HtmlElement */
441   public Textarea onblur(String value) {
442      super.onblur(value);
443      return this;
444   }
445
446   @Override /* Overridden from HtmlElement */
447   public Textarea oncancel(String value) {
448      super.oncancel(value);
449      return this;
450   }
451
452   @Override /* Overridden from HtmlElement */
453   public Textarea oncanplay(String value) {
454      super.oncanplay(value);
455      return this;
456   }
457
458   @Override /* Overridden from HtmlElement */
459   public Textarea oncanplaythrough(String value) {
460      super.oncanplaythrough(value);
461      return this;
462   }
463
464   @Override /* Overridden from HtmlElement */
465   public Textarea onchange(String value) {
466      super.onchange(value);
467      return this;
468   }
469
470   @Override /* Overridden from HtmlElement */
471   public Textarea onclick(String value) {
472      super.onclick(value);
473      return this;
474   }
475
476   @Override /* Overridden from HtmlElement */
477   public Textarea oncuechange(String value) {
478      super.oncuechange(value);
479      return this;
480   }
481
482   @Override /* Overridden from HtmlElement */
483   public Textarea ondblclick(String value) {
484      super.ondblclick(value);
485      return this;
486   }
487
488   @Override /* Overridden from HtmlElement */
489   public Textarea ondurationchange(String value) {
490      super.ondurationchange(value);
491      return this;
492   }
493
494   @Override /* Overridden from HtmlElement */
495   public Textarea onemptied(String value) {
496      super.onemptied(value);
497      return this;
498   }
499
500   @Override /* Overridden from HtmlElement */
501   public Textarea onended(String value) {
502      super.onended(value);
503      return this;
504   }
505
506   @Override /* Overridden from HtmlElement */
507   public Textarea onerror(String value) {
508      super.onerror(value);
509      return this;
510   }
511
512   @Override /* Overridden from HtmlElement */
513   public Textarea onfocus(String value) {
514      super.onfocus(value);
515      return this;
516   }
517
518   @Override /* Overridden from HtmlElement */
519   public Textarea oninput(String value) {
520      super.oninput(value);
521      return this;
522   }
523
524   @Override /* Overridden from HtmlElement */
525   public Textarea oninvalid(String value) {
526      super.oninvalid(value);
527      return this;
528   }
529
530   @Override /* Overridden from HtmlElement */
531   public Textarea onkeydown(String value) {
532      super.onkeydown(value);
533      return this;
534   }
535
536   @Override /* Overridden from HtmlElement */
537   public Textarea onkeypress(String value) {
538      super.onkeypress(value);
539      return this;
540   }
541
542   @Override /* Overridden from HtmlElement */
543   public Textarea onkeyup(String value) {
544      super.onkeyup(value);
545      return this;
546   }
547
548   @Override /* Overridden from HtmlElement */
549   public Textarea onload(String value) {
550      super.onload(value);
551      return this;
552   }
553
554   @Override /* Overridden from HtmlElement */
555   public Textarea onloadeddata(String value) {
556      super.onloadeddata(value);
557      return this;
558   }
559
560   @Override /* Overridden from HtmlElement */
561   public Textarea onloadedmetadata(String value) {
562      super.onloadedmetadata(value);
563      return this;
564   }
565
566   @Override /* Overridden from HtmlElement */
567   public Textarea onloadstart(String value) {
568      super.onloadstart(value);
569      return this;
570   }
571
572   @Override /* Overridden from HtmlElement */
573   public Textarea onmousedown(String value) {
574      super.onmousedown(value);
575      return this;
576   }
577
578   @Override /* Overridden from HtmlElement */
579   public Textarea onmouseenter(String value) {
580      super.onmouseenter(value);
581      return this;
582   }
583
584   @Override /* Overridden from HtmlElement */
585   public Textarea onmouseleave(String value) {
586      super.onmouseleave(value);
587      return this;
588   }
589
590   @Override /* Overridden from HtmlElement */
591   public Textarea onmousemove(String value) {
592      super.onmousemove(value);
593      return this;
594   }
595
596   @Override /* Overridden from HtmlElement */
597   public Textarea onmouseout(String value) {
598      super.onmouseout(value);
599      return this;
600   }
601
602   @Override /* Overridden from HtmlElement */
603   public Textarea onmouseover(String value) {
604      super.onmouseover(value);
605      return this;
606   }
607
608   @Override /* Overridden from HtmlElement */
609   public Textarea onmouseup(String value) {
610      super.onmouseup(value);
611      return this;
612   }
613
614   @Override /* Overridden from HtmlElement */
615   public Textarea onmousewheel(String value) {
616      super.onmousewheel(value);
617      return this;
618   }
619
620   @Override /* Overridden from HtmlElement */
621   public Textarea onpause(String value) {
622      super.onpause(value);
623      return this;
624   }
625
626   @Override /* Overridden from HtmlElement */
627   public Textarea onplay(String value) {
628      super.onplay(value);
629      return this;
630   }
631
632   @Override /* Overridden from HtmlElement */
633   public Textarea onplaying(String value) {
634      super.onplaying(value);
635      return this;
636   }
637
638   @Override /* Overridden from HtmlElement */
639   public Textarea onprogress(String value) {
640      super.onprogress(value);
641      return this;
642   }
643
644   @Override /* Overridden from HtmlElement */
645   public Textarea onratechange(String value) {
646      super.onratechange(value);
647      return this;
648   }
649
650   @Override /* Overridden from HtmlElement */
651   public Textarea onreset(String value) {
652      super.onreset(value);
653      return this;
654   }
655
656   @Override /* Overridden from HtmlElement */
657   public Textarea onresize(String value) {
658      super.onresize(value);
659      return this;
660   }
661
662   @Override /* Overridden from HtmlElement */
663   public Textarea onscroll(String value) {
664      super.onscroll(value);
665      return this;
666   }
667
668   @Override /* Overridden from HtmlElement */
669   public Textarea onseeked(String value) {
670      super.onseeked(value);
671      return this;
672   }
673
674   @Override /* Overridden from HtmlElement */
675   public Textarea onseeking(String value) {
676      super.onseeking(value);
677      return this;
678   }
679
680   @Override /* Overridden from HtmlElement */
681   public Textarea onselect(String value) {
682      super.onselect(value);
683      return this;
684   }
685
686   @Override /* Overridden from HtmlElement */
687   public Textarea onshow(String value) {
688      super.onshow(value);
689      return this;
690   }
691
692   @Override /* Overridden from HtmlElement */
693   public Textarea onstalled(String value) {
694      super.onstalled(value);
695      return this;
696   }
697
698   @Override /* Overridden from HtmlElement */
699   public Textarea onsubmit(String value) {
700      super.onsubmit(value);
701      return this;
702   }
703
704   @Override /* Overridden from HtmlElement */
705   public Textarea onsuspend(String value) {
706      super.onsuspend(value);
707      return this;
708   }
709
710   @Override /* Overridden from HtmlElement */
711   public Textarea ontimeupdate(String value) {
712      super.ontimeupdate(value);
713      return this;
714   }
715
716   @Override /* Overridden from HtmlElement */
717   public Textarea ontoggle(String value) {
718      super.ontoggle(value);
719      return this;
720   }
721
722   @Override /* Overridden from HtmlElement */
723   public Textarea onvolumechange(String value) {
724      super.onvolumechange(value);
725      return this;
726   }
727
728   @Override /* Overridden from HtmlElement */
729   public Textarea onwaiting(String value) {
730      super.onwaiting(value);
731      return this;
732   }
733
734   @Override /* Overridden from HtmlElement */
735   public Textarea spellcheck(Object value) {
736      super.spellcheck(value);
737      return this;
738   }
739
740   @Override /* Overridden from HtmlElement */
741   public Textarea style(String value) {
742      super.style(value);
743      return this;
744   }
745
746   @Override /* Overridden from HtmlElement */
747   public Textarea tabindex(Object value) {
748      super.tabindex(value);
749      return this;
750   }
751
752   @Override /* Overridden from HtmlElement */
753   public Textarea title(String value) {
754      super.title(value);
755      return this;
756   }
757
758   @Override /* Overridden from HtmlElement */
759   public Textarea translate(Object value) {
760      super.translate(value);
761      return this;
762   }
763
764   @Override /* Overridden from HtmlElementRawText */
765   public Textarea text(Object value) {
766      super.text(value);
767      return this;
768   }
769}