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-form-element <form>} 023 * element. 024 * 025 * <ul class='seealso'> 026 * <li class='link'>{@doc DtoHtml5} 027 * </ul> 028 */ 029@Bean(typeName="form") 030public class Form extends HtmlElementMixed { 031 032 /** 033 * Creates an empty {@link Form} element. 034 */ 035 public Form() {} 036 037 /** 038 * Creates a {@link Form} element with the specified {@link Form#action(String)} attribute. 039 * 040 * @param action The {@link Form#action(String)} attribute. 041 */ 042 public Form(String action) { 043 action(action); 044 } 045 046 /** 047 * Creates an {@link Form} element with the specified {@link Form#action(String)} attribute and child nodes. 048 * 049 * @param action The {@link Form#action(String)} attribute. 050 * @param children The child nodes. 051 */ 052 public Form(String action, Object...children) { 053 action(action).children(children); 054 } 055 056 /** 057 * {@doc ExtHTML5.forms#attr-form-accept-charset accept-charset} 058 * attribute. 059 * 060 * <p> 061 * Character encodings to use for form submission. 062 * 063 * @param acceptcharset The new value for this attribute. 064 * @return This object (for method chaining). 065 */ 066 public final Form acceptcharset(String acceptcharset) { 067 attr("accept-charset", acceptcharset); 068 return this; 069 } 070 071 /** 072 * {@doc ExtHTML5.forms#attr-fs-action action} attribute. 073 * 074 * <p> 075 * URL to use for form submission. 076 * 077 * <p> 078 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 079 * Strings must be valid URIs. 080 * 081 * <p> 082 * URIs defined by {@link UriResolver} can be used for values. 083 * 084 * @param action The new value for this attribute. 085 * @return This object (for method chaining). 086 */ 087 public final Form action(String action) { 088 attrUri("action", action); 089 return this; 090 } 091 092 /** 093 * {@doc ExtHTML5.forms#attr-form-autocomplete autocomplete} 094 * attribute. 095 * 096 * <p> 097 * Default setting for auto-fill feature for controls in the form. 098 * 099 * @param autocomplete The new value for this attribute. 100 * @return This object (for method chaining). 101 */ 102 public final Form autocomplete(String autocomplete) { 103 attr("autocomplete", autocomplete); 104 return this; 105 } 106 107 /** 108 * {@doc ExtHTML5.forms#attr-fs-enctype enctype} attribute. 109 * 110 * <p> 111 * Form data set encoding type to use for form submission. 112 * 113 * @param enctype The new value for this attribute. 114 * @return This object (for method chaining). 115 */ 116 public final Form enctype(String enctype) { 117 attr("enctype", enctype); 118 return this; 119 } 120 121 /** 122 * {@doc ExtHTML5.forms#attr-fs-method method} attribute. 123 * 124 * <p> 125 * HTTP method to use for form submission. 126 * 127 * @param method The new value for this attribute. 128 * @return This object (for method chaining). 129 */ 130 public final Form method(String method) { 131 attr("method", method); 132 return this; 133 } 134 135 /** 136 * {@doc ExtHTML5.forms#attr-form-name name} attribute. 137 * 138 * <p> 139 * Name of form to use in the document.forms API. 140 * 141 * @param name The new value for this attribute. 142 * @return This object (for method chaining). 143 */ 144 public final Form name(String name) { 145 attr("name", name); 146 return this; 147 } 148 149 /** 150 * {@doc ExtHTML5.forms#attr-fs-novalidate novalidate} attribute. 151 * 152 * <p> 153 * Bypass form control validation for form submission. 154 * 155 * @param novalidate The new value for this attribute. 156 * Typically a {@link Boolean} or {@link String}. 157 * @return This object (for method chaining). 158 */ 159 public final Form novalidate(Boolean novalidate) { 160 attr("novalidate", novalidate); 161 return this; 162 } 163 164 /** 165 * {@doc ExtHTML5.forms#attr-fs-target target} attribute. 166 * 167 * <p> 168 * Browsing context for form submission. 169 * 170 * @param target The new value for this attribute. 171 * @return This object (for method chaining). 172 */ 173 public final Form target(String target) { 174 attr("target", target); 175 return this; 176 } 177 178 179 //----------------------------------------------------------------------------------------------------------------- 180 // Overridden methods 181 //----------------------------------------------------------------------------------------------------------------- 182 183 184 @Override /* HtmlElement */ 185 public final Form _class(String _class) { 186 super._class(_class); 187 return this; 188 } 189 190 @Override /* HtmlElement */ 191 public final Form id(String id) { 192 super.id(id); 193 return this; 194 } 195 196 @Override /* HtmlElement */ 197 public final Form style(String style) { 198 super.style(style); 199 return this; 200 } 201 202 @Override /* HtmlElementMixed */ 203 public Form children(Object...children) { 204 super.children(children); 205 return this; 206 } 207 208 @Override /* HtmlElementMixed */ 209 public Form child(Object child) { 210 super.child(child); 211 return this; 212 } 213}