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.*;
016import java.net.URI;
017
018import org.apache.juneau.*;
019import org.apache.juneau.annotation.*;
020
021/**
022 * DTO for an HTML {@doc HTML5.forms#the-button-element <button>}
023 * element.
024 *
025 * <h5 class='section'>See Also:</h5>
026 * <ul class='doctree'>
027 *    <li class='link'>{@doc juneau-dto.HTML5}
028 * </ul>
029 */
030@Bean(typeName="button")
031public class Button extends HtmlElementMixed {
032
033   /**
034    * {@doc HTML5.forms#attr-fe-autofocus autofocus} attribute.
035    *
036    * <p>
037    * Automatically focus the form control when the page is loaded.
038    *
039    * @param autofocus
040    *    The new value for this attribute.
041    *    Typically a {@link Boolean} or {@link String}.
042    * @return This object (for method chaining).
043    */
044   public final Button autofocus(Object autofocus) {
045      attr("autofocus", autofocus);
046      return this;
047   }
048
049   /**
050    * {@doc HTML5.forms#attr-fe-disabled disabled} attribute.
051    *
052    * <p>
053    * Whether the form control is disabled.
054    *
055    * @param disabled
056    *    The new value for this attribute.
057    *    Typically a {@link Boolean} or {@link String}.
058    * @return This object (for method chaining).
059    */
060   public final Button disabled(Object disabled) {
061      attr("disabled", deminimize(disabled, "disabled"));
062      return this;
063   }
064
065   /**
066    * {@doc HTML5.forms#attr-fae-form form} attribute.
067    *
068    * <p>
069    * Associates the control with a form element.
070    *
071    * @param form The new value for this attribute.
072    * @return This object (for method chaining).
073    */
074   public final Button form(String form) {
075      attr("form", form);
076      return this;
077   }
078
079   /**
080    * {@doc HTML5.forms#attr-fs-formaction formaction} attribute.
081    *
082    * <p>
083    * URL to use for form submission.
084    *
085    * <p>
086    * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
087    * Strings must be valid URIs.
088    *
089    * <p>
090    * URIs defined by {@link UriResolver} can be used for values.
091    *
092    * @param formaction The new value for this attribute.
093    * @return This object (for method chaining).
094    */
095   public final Button formaction(String formaction) {
096      attrUri("formaction", formaction);
097      return this;
098   }
099
100   /**
101    * {@doc HTML5.forms#attr-fs-formenctype formenctype} attribute.
102    *
103    * <p>
104    * Form data set encoding type to use for form submission.
105    *
106    * @param formenctype The new value for this attribute.
107    * @return This object (for method chaining).
108    */
109   public final Button formenctype(String formenctype) {
110      attr("formenctype", formenctype);
111      return this;
112   }
113
114   /**
115    * {@doc HTML5.forms#attr-fs-formmethod formmethod} attribute.
116    *
117    * <p>
118    * HTTP method to use for form submission.
119    *
120    * @param formmethod The new value for this attribute.
121    * @return This object (for method chaining).
122    */
123   public final Button formmethod(String formmethod) {
124      attr("formmethod", formmethod);
125      return this;
126   }
127
128   /**
129    * {@doc HTML5.forms#attr-fs-formnovalidate formnovalidate}
130    * attribute.
131    *
132    * <p>
133    * Bypass form control validation for form submission.
134    *
135    * @param formnovalidate The new value for this attribute.
136    * @return This object (for method chaining).
137    */
138   public final Button formnovalidate(String formnovalidate) {
139      attr("formnovalidate", formnovalidate);
140      return this;
141   }
142
143   /**
144    * {@doc HTML5.forms#attr-fs-formtarget formtarget} attribute.
145    *
146    * <p>
147    * Browsing context for form submission.
148    *
149    * @param formtarget The new value for this attribute.
150    * @return This object (for method chaining).
151    */
152   public final Button formtarget(String formtarget) {
153      attr("formtarget", formtarget);
154      return this;
155   }
156
157   /**
158    * {@doc HTML5.forms#attr-fs-menu menu} attribute.
159    *
160    * <p>
161    * Specifies the element's designated pop-up menu.
162    *
163    * @param menu The new value for this attribute.
164    * @return This object (for method chaining).
165    */
166   public final Button menu(String menu) {
167      attr("menu", menu);
168      return this;
169   }
170
171   /**
172    * {@doc HTML5.forms#attr-fe-name name} attribute.
173    *
174    * <p>
175    * Name of form control to use for form submission and in the form.elements API.
176    *
177    * @param name The new value for this attribute.
178    * @return This object (for method chaining).
179    */
180   public final Button name(String name) {
181      attr("name", name);
182      return this;
183   }
184
185   /**
186    * {@doc HTML5.forms#attr-button-type type} attribute.
187    *
188    * <p>
189    * Type of button.
190    *
191    * @param type The new value for this attribute.
192    * @return This object (for method chaining).
193    */
194   public final Button type(String type) {
195      attr("type", type);
196      return this;
197   }
198
199   /**
200    * {@doc HTML5.forms#attr-button-value value} attribute.
201    *
202    * <p>
203    * Value to be used for form submission.
204    *
205    * @param value
206    *    The new value for this attribute.
207    *    Typically a {@link Number} or {@link String}.
208    * @return This object (for method chaining).
209    */
210   public final Button value(Object value) {
211      attr("value", value);
212      return this;
213   }
214
215
216   //-----------------------------------------------------------------------------------------------------------------
217   // Overridden methods
218   //-----------------------------------------------------------------------------------------------------------------
219
220   @Override /* HtmlElement */
221   public final Button _class(String _class) {
222      super._class(_class);
223      return this;
224   }
225
226   @Override /* HtmlElement */
227   public final Button id(String id) {
228      super.id(id);
229      return this;
230   }
231
232   @Override /* HtmlElement */
233   public final Button style(String style) {
234      super.style(style);
235      return this;
236   }
237
238   @Override /* HtmlElementMixed */
239   public Button children(Object...children) {
240      super.children(children);
241      return this;
242   }
243
244   @Override /* HtmlElementMixed */
245   public Button child(Object child) {
246      super.child(child);
247      return this;
248   }
249}