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