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 org.apache.juneau.annotation.*; 016 017/** 018 * DTO for an HTML {@doc ExtHTML5.forms#the-option-element <option>} 019 * element. 020 * 021 * <ul class='seealso'> 022 * <li class='link'>{@doc DtoHtml5} 023 * </ul> 024 */ 025@Bean(typeName="option") 026public class Option extends HtmlElementText { 027 028 /** 029 * Creates an empty {@link Option} element. 030 */ 031 public Option() {} 032 033 /** 034 * Creates an {@link Option} element with the specified {@link Option#text(Object)} attribute. 035 * 036 * @param text The {@link Option#text(Object)} attribute. 037 */ 038 public Option(Object text) { 039 text(text); 040 } 041 042 /** 043 * Creates an {@link Option} element with the specified {@link Option#value(Object)} attribute and 044 * {@link Option#text(Object)} node. 045 * 046 * @param value The {@link Option#value(Object)} attribute. 047 * @param text The {@link Option#text(Object)} node. 048 */ 049 public Option(Object value, Object text) { 050 value(value).text(text); 051 } 052 053 /** 054 * {@doc ExtHTML5.forms#attr-option-disabled disabled} attribute. 055 * 056 * <p> 057 * Whether the form control is disabled. 058 * 059 * @param disabled 060 * The new value for this attribute. 061 * Typically a {@link Boolean} or {@link String}. 062 * @return This object (for method chaining). 063 */ 064 public final Option disabled(Object disabled) { 065 attr("disabled", deminimize(disabled, "disabled")); 066 return this; 067 } 068 069 /** 070 * {@doc ExtHTML5.forms#attr-option-label label} attribute. 071 * 072 * <p> 073 * User-visible label. 074 * 075 * @param label The new value for this attribute. 076 * @return This object (for method chaining). 077 */ 078 public final Option label(String label) { 079 attr("label", label); 080 return this; 081 } 082 083 /** 084 * {@doc ExtHTML5.forms#attr-option-selected selected} attribute. 085 * 086 * <p> 087 * Whether the option is selected by default. 088 * 089 * @param selected 090 * The new value for this attribute. 091 * Typically a {@link Boolean} or {@link String}. 092 * @return This object (for method chaining). 093 */ 094 public final Option selected(Object selected) { 095 attr("selected", deminimize(selected, "selected")); 096 return this; 097 } 098 099 /** 100 * {@doc ExtHTML5.forms#attr-option-value value} attribute. 101 * 102 * <p> 103 * Value to be used for form submission. 104 * 105 * @param value 106 * The new value for this attribute. 107 * Typically a {@link Number} or {@link String}. 108 * @return This object (for method chaining). 109 */ 110 public final Option value(Object value) { 111 attr("value", value); 112 return this; 113 } 114 115 116 //----------------------------------------------------------------------------------------------------------------- 117 // Overridden methods 118 //----------------------------------------------------------------------------------------------------------------- 119 120 @Override /* HtmlElement */ 121 public final Option _class(String _class) { 122 super._class(_class); 123 return this; 124 } 125 126 @Override /* HtmlElement */ 127 public final Option id(String id) { 128 super.id(id); 129 return this; 130 } 131 132 @Override /* HtmlElement */ 133 public final Option style(String style) { 134 super.style(style); 135 return this; 136 } 137 138 @Override /* HtmlElementText */ 139 public Option text(Object text) { 140 super.text(text); 141 return this; 142 } 143}