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