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 static org.apache.juneau.common.internal.StringUtils.*;
016
017import org.apache.juneau.annotation.*;
018import org.apache.juneau.internal.*;
019
020/**
021 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#the-select-element">&lt;select&gt;</a>
022 * element.
023 *
024 * <h5 class='section'>See Also:</h5><ul>
025 *    <li class='link'><a class="doclink" href="../../../../../index.html#jd.Html5">Overview &gt; juneau-dto &gt; HTML5</a>
026 * </ul>
027 */
028@Bean(typeName="select")
029@FluentSetters
030public class Select extends HtmlElementContainer {
031
032   /**
033    * Creates an empty {@link Select} element.
034    */
035   public Select() {}
036
037   /**
038    * Creates a {@link Select} element with the specified {@link Select#name(String)} attribute and child nodes.
039    *
040    * @param name The {@link Select#name(String)} attribute.
041    * @param children The child nodes.
042    */
043   public Select(String name, Object...children) {
044      name(name).children(children);
045   }
046
047   /**
048    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus">autofocus</a> attribute.
049    *
050    * <p>
051    * Automatically focus the form control when the page is loaded.
052    *
053    * @param autofocus
054    *    The new value for this attribute.
055    *    Typically a {@link Boolean} or {@link String}.
056    * @return This object.
057    */
058   public final Select autofocus(Object autofocus) {
059      attr("autofocus", autofocus);
060      return this;
061   }
062
063   /**
064    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-disabled">disabled</a> attribute.
065    *
066    * <p>
067    * Whether the form control is disabled.
068    *
069    * @param disabled
070    *    The new value for this attribute.
071    *    Typically a {@link Boolean} or {@link String}.
072    * @return This object.
073    */
074   public final Select disabled(Object disabled) {
075      attr("disabled", deminimize(disabled, "disabled"));
076      return this;
077   }
078
079   /**
080    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute.
081    *
082    * <p>
083    * Associates the control with a form element.
084    *
085    * @param form The new value for this attribute.
086    * @return This object.
087    */
088   public final Select form(String form) {
089      attr("form", form);
090      return this;
091   }
092
093   /**
094    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-select-multiple">multiple</a> attribute.
095    *
096    * <p>
097    * Whether to allow multiple values.
098    *
099    * @param multiple
100    *    The new value for this attribute.
101    *    Typically a {@link Boolean} or {@link String}.
102    * @return This object.
103    */
104   public final Select multiple(Object multiple) {
105      attr("multiple", deminimize(multiple, "multiple"));
106      return this;
107   }
108
109   /**
110    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-name">name</a> attribute.
111    *
112    * <p>
113    * Name of form control to use for form submission and in the form.elements API.
114    *
115    * @param name The new value for this attribute.
116    * @return This object.
117    */
118   public final Select name(String name) {
119      attr("name", name);
120      return this;
121   }
122
123   /**
124    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-select-required">required</a> attribute.
125    *
126    * <p>
127    * Whether the control is required for form submission.
128    *
129    * @param required
130    *    The new value for this attribute.
131    *    Typically a {@link Boolean} or {@link String}.
132    * @return This object.
133    */
134   public final Select required(Object required) {
135      attr("required", required);
136      return this;
137   }
138
139   /**
140    * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-select-size">size</a> attribute.
141    *
142    * <p>
143    * Size of the control.
144    *
145    * @param size
146    *    The new value for this attribute.
147    *    Typically a {@link Number} or {@link String}.
148    * @return This object.
149    */
150   public final Select size(Object size) {
151      attr("size", size);
152      return this;
153   }
154
155   /**
156    * Convenience method for selecting a child {@link Option} after the options have already been populated.
157    *
158    * @param optionValue The option value.
159    * @return This object.
160    */
161   public Select choose(Object optionValue) {
162      if (optionValue != null) {
163         getChildren().forEach(x -> {
164            if (x instanceof Option) {
165               Option o = (Option)x;
166               if (eq(optionValue.toString(), o.getAttr(String.class, "value")))
167                  o.selected(true);
168            }
169         });
170      }
171      return this;
172   }
173
174   //-----------------------------------------------------------------------------------------------------------------
175   // Overridden methods
176   //-----------------------------------------------------------------------------------------------------------------
177
178   // <FluentSetters>
179
180   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
181   public Select _class(String _class) {
182      super._class(_class);
183      return this;
184   }
185
186   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
187   public Select accesskey(String accesskey) {
188      super.accesskey(accesskey);
189      return this;
190   }
191
192   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
193   public Select contenteditable(Object contenteditable) {
194      super.contenteditable(contenteditable);
195      return this;
196   }
197
198   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
199   public Select dir(String dir) {
200      super.dir(dir);
201      return this;
202   }
203
204   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
205   public Select hidden(Object hidden) {
206      super.hidden(hidden);
207      return this;
208   }
209
210   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
211   public Select id(String id) {
212      super.id(id);
213      return this;
214   }
215
216   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
217   public Select lang(String lang) {
218      super.lang(lang);
219      return this;
220   }
221
222   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
223   public Select onabort(String onabort) {
224      super.onabort(onabort);
225      return this;
226   }
227
228   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
229   public Select onblur(String onblur) {
230      super.onblur(onblur);
231      return this;
232   }
233
234   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
235   public Select oncancel(String oncancel) {
236      super.oncancel(oncancel);
237      return this;
238   }
239
240   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
241   public Select oncanplay(String oncanplay) {
242      super.oncanplay(oncanplay);
243      return this;
244   }
245
246   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
247   public Select oncanplaythrough(String oncanplaythrough) {
248      super.oncanplaythrough(oncanplaythrough);
249      return this;
250   }
251
252   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
253   public Select onchange(String onchange) {
254      super.onchange(onchange);
255      return this;
256   }
257
258   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
259   public Select onclick(String onclick) {
260      super.onclick(onclick);
261      return this;
262   }
263
264   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
265   public Select oncuechange(String oncuechange) {
266      super.oncuechange(oncuechange);
267      return this;
268   }
269
270   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
271   public Select ondblclick(String ondblclick) {
272      super.ondblclick(ondblclick);
273      return this;
274   }
275
276   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
277   public Select ondurationchange(String ondurationchange) {
278      super.ondurationchange(ondurationchange);
279      return this;
280   }
281
282   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
283   public Select onemptied(String onemptied) {
284      super.onemptied(onemptied);
285      return this;
286   }
287
288   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
289   public Select onended(String onended) {
290      super.onended(onended);
291      return this;
292   }
293
294   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
295   public Select onerror(String onerror) {
296      super.onerror(onerror);
297      return this;
298   }
299
300   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
301   public Select onfocus(String onfocus) {
302      super.onfocus(onfocus);
303      return this;
304   }
305
306   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
307   public Select oninput(String oninput) {
308      super.oninput(oninput);
309      return this;
310   }
311
312   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
313   public Select oninvalid(String oninvalid) {
314      super.oninvalid(oninvalid);
315      return this;
316   }
317
318   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
319   public Select onkeydown(String onkeydown) {
320      super.onkeydown(onkeydown);
321      return this;
322   }
323
324   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
325   public Select onkeypress(String onkeypress) {
326      super.onkeypress(onkeypress);
327      return this;
328   }
329
330   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
331   public Select onkeyup(String onkeyup) {
332      super.onkeyup(onkeyup);
333      return this;
334   }
335
336   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
337   public Select onload(String onload) {
338      super.onload(onload);
339      return this;
340   }
341
342   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
343   public Select onloadeddata(String onloadeddata) {
344      super.onloadeddata(onloadeddata);
345      return this;
346   }
347
348   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
349   public Select onloadedmetadata(String onloadedmetadata) {
350      super.onloadedmetadata(onloadedmetadata);
351      return this;
352   }
353
354   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
355   public Select onloadstart(String onloadstart) {
356      super.onloadstart(onloadstart);
357      return this;
358   }
359
360   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
361   public Select onmousedown(String onmousedown) {
362      super.onmousedown(onmousedown);
363      return this;
364   }
365
366   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
367   public Select onmouseenter(String onmouseenter) {
368      super.onmouseenter(onmouseenter);
369      return this;
370   }
371
372   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
373   public Select onmouseleave(String onmouseleave) {
374      super.onmouseleave(onmouseleave);
375      return this;
376   }
377
378   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
379   public Select onmousemove(String onmousemove) {
380      super.onmousemove(onmousemove);
381      return this;
382   }
383
384   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
385   public Select onmouseout(String onmouseout) {
386      super.onmouseout(onmouseout);
387      return this;
388   }
389
390   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
391   public Select onmouseover(String onmouseover) {
392      super.onmouseover(onmouseover);
393      return this;
394   }
395
396   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
397   public Select onmouseup(String onmouseup) {
398      super.onmouseup(onmouseup);
399      return this;
400   }
401
402   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
403   public Select onmousewheel(String onmousewheel) {
404      super.onmousewheel(onmousewheel);
405      return this;
406   }
407
408   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
409   public Select onpause(String onpause) {
410      super.onpause(onpause);
411      return this;
412   }
413
414   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
415   public Select onplay(String onplay) {
416      super.onplay(onplay);
417      return this;
418   }
419
420   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
421   public Select onplaying(String onplaying) {
422      super.onplaying(onplaying);
423      return this;
424   }
425
426   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
427   public Select onprogress(String onprogress) {
428      super.onprogress(onprogress);
429      return this;
430   }
431
432   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
433   public Select onratechange(String onratechange) {
434      super.onratechange(onratechange);
435      return this;
436   }
437
438   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
439   public Select onreset(String onreset) {
440      super.onreset(onreset);
441      return this;
442   }
443
444   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
445   public Select onresize(String onresize) {
446      super.onresize(onresize);
447      return this;
448   }
449
450   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
451   public Select onscroll(String onscroll) {
452      super.onscroll(onscroll);
453      return this;
454   }
455
456   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
457   public Select onseeked(String onseeked) {
458      super.onseeked(onseeked);
459      return this;
460   }
461
462   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
463   public Select onseeking(String onseeking) {
464      super.onseeking(onseeking);
465      return this;
466   }
467
468   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
469   public Select onselect(String onselect) {
470      super.onselect(onselect);
471      return this;
472   }
473
474   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
475   public Select onshow(String onshow) {
476      super.onshow(onshow);
477      return this;
478   }
479
480   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
481   public Select onstalled(String onstalled) {
482      super.onstalled(onstalled);
483      return this;
484   }
485
486   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
487   public Select onsubmit(String onsubmit) {
488      super.onsubmit(onsubmit);
489      return this;
490   }
491
492   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
493   public Select onsuspend(String onsuspend) {
494      super.onsuspend(onsuspend);
495      return this;
496   }
497
498   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
499   public Select ontimeupdate(String ontimeupdate) {
500      super.ontimeupdate(ontimeupdate);
501      return this;
502   }
503
504   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
505   public Select ontoggle(String ontoggle) {
506      super.ontoggle(ontoggle);
507      return this;
508   }
509
510   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
511   public Select onvolumechange(String onvolumechange) {
512      super.onvolumechange(onvolumechange);
513      return this;
514   }
515
516   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
517   public Select onwaiting(String onwaiting) {
518      super.onwaiting(onwaiting);
519      return this;
520   }
521
522   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
523   public Select spellcheck(Object spellcheck) {
524      super.spellcheck(spellcheck);
525      return this;
526   }
527
528   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
529   public Select style(String style) {
530      super.style(style);
531      return this;
532   }
533
534   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
535   public Select tabindex(Object tabindex) {
536      super.tabindex(tabindex);
537      return this;
538   }
539
540   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
541   public Select title(String title) {
542      super.title(title);
543      return this;
544   }
545
546   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */
547   public Select translate(Object translate) {
548      super.translate(translate);
549      return this;
550   }
551
552   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElementContainer */
553   public Select child(Object child) {
554      super.child(child);
555      return this;
556   }
557
558   @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElementContainer */
559   public Select children(Object...children) {
560      super.children(children);
561      return this;
562   }
563
564   // </FluentSetters>
565}