001 package org.apache.myfaces.tobago.taglib.extension;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one or more
005 * contributor license agreements. See the NOTICE file distributed with
006 * this work for additional information regarding copyright ownership.
007 * The ASF licenses this file to You under the Apache License, Version 2.0
008 * (the "License"); you may not use this file except in compliance with
009 * the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
021 import org.apache.myfaces.tobago.apt.annotation.Tag;
022 import org.apache.myfaces.tobago.taglib.component.TimeTag;
023 import org.apache.myfaces.tobago.taglib.decl.HasConverter;
024 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
025 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
026 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
027 import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
028 import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
029 import org.apache.myfaces.tobago.taglib.decl.HasTip;
030 import org.apache.myfaces.tobago.taglib.decl.HasValidator;
031 import org.apache.myfaces.tobago.taglib.decl.HasValue;
032 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
033 import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
034 import org.apache.myfaces.tobago.taglib.decl.IsFocus;
035 import org.apache.myfaces.tobago.taglib.decl.IsInline;
036 import org.apache.myfaces.tobago.taglib.decl.IsReadonly;
037 import org.apache.myfaces.tobago.taglib.decl.IsRequired;
038
039 import javax.servlet.jsp.JspException;
040 import javax.servlet.jsp.tagext.BodyTagSupport;
041
042 /**
043 * Renders a time input field with a label.
044 * <br />
045 * Short syntax of:
046 * <p/>
047 * <pre>
048 * <tc:panel>
049 * <f:facet name="layout">
050 * <tc:gridLayout columns="fixed;*"/>
051 * </f:facet>
052 * <tc:label value="#{label}" for="@auto"/>
053 * <tc:time value="#{value}">
054 * ...
055 * </tc:in>
056 * </tc:panel>
057 * </pre>
058 */
059 @Tag(name = "time")
060 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.TimeTag")
061 public class TimeExtensionTag extends BodyTagSupport
062 implements HasValue, HasValueChangeListener, HasValidator, HasIdBindingAndRendered,
063 HasConverter, IsReadonly, IsDisabled, HasOnchange, IsRequired, HasTip,
064 HasLabel, HasLabelWidth, IsFocus, IsInline, HasTabIndex {
065
066 private String binding;
067 private String converter;
068 private String validator;
069 private String disabled;
070 private String focus;
071 private String label;
072 private String readonly;
073 private String rendered;
074 private String required;
075 private String tip;
076 private String value;
077 private String valueChangeListener;
078 private String inline;
079 private String onchange;
080 private String labelWidth;
081 private String tabIndex;
082
083 private LabelExtensionTag labelTag;
084 private TimeTag timeTag;
085
086 @Override
087 public int doStartTag() throws JspException {
088
089 labelTag = new LabelExtensionTag();
090 labelTag.setPageContext(pageContext);
091 if (label != null) {
092 labelTag.setValue(label);
093 }
094 if (tip != null) {
095 labelTag.setTip(tip);
096 }
097 if (rendered != null) {
098 labelTag.setRendered(rendered);
099 }
100 if (labelWidth != null) {
101 labelTag.setColumns(labelWidth + ";*");
102 }
103 labelTag.setParent(getParent());
104 labelTag.doStartTag();
105
106 timeTag = new TimeTag();
107 timeTag.setPageContext(pageContext);
108 if (value != null) {
109 timeTag.setValue(value);
110 }
111 if (valueChangeListener != null) {
112 timeTag.setValueChangeListener(valueChangeListener);
113 }
114 if (binding != null) {
115 timeTag.setBinding(binding);
116 }
117 if (converter != null) {
118 timeTag.setConverter(converter);
119 }
120 if (validator != null) {
121 timeTag.setValidator(validator);
122 }
123 if (onchange != null) {
124 timeTag.setOnchange(onchange);
125 }
126 if (disabled != null) {
127 timeTag.setDisabled(disabled);
128 }
129 if (focus != null) {
130 timeTag.setFocus(focus);
131 }
132 if (id != null) {
133 timeTag.setId(id);
134 }
135 if (inline != null) {
136 timeTag.setInline(inline);
137 }
138 if (readonly != null) {
139 timeTag.setReadonly(readonly);
140 }
141 if (required != null) {
142 timeTag.setRequired(required);
143 }
144 if (tabIndex != null) {
145 timeTag.setTabIndex(tabIndex);
146 }
147 timeTag.setParent(labelTag);
148 timeTag.doStartTag();
149
150 return super.doStartTag();
151 }
152
153 @Override
154 public int doEndTag() throws JspException {
155 timeTag.doEndTag();
156 labelTag.doEndTag();
157 return super.doEndTag();
158 }
159
160 @Override
161 public void release() {
162 super.release();
163 binding = null;
164 converter = null;
165 validator = null;
166 disabled = null;
167 labelWidth = null;
168 focus = null;
169 label = null;
170 inline = null;
171 readonly = null;
172 rendered = null;
173 required = null;
174 tip = null;
175 value = null;
176 onchange = null;
177 valueChangeListener = null;
178 tabIndex = null;
179 timeTag = null;
180 labelTag = null;
181 }
182
183 public void setValue(String value) {
184 this.value = value;
185 }
186
187 public void setValueChangeListener(String valueChangeListener) {
188 this.valueChangeListener = valueChangeListener;
189 }
190
191 public void setLabel(String label) {
192 this.label = label;
193 }
194
195 public void setFocus(String focus) {
196 this.focus = focus;
197 }
198
199 public void setBinding(String binding) {
200 this.binding = binding;
201 }
202
203 public void setRendered(String rendered) {
204 this.rendered = rendered;
205 }
206
207 public void setConverter(String converter) {
208 this.converter = converter;
209 }
210
211 public void setValidator(String validator) {
212 this.validator = validator;
213 }
214
215 public void setOnchange(String onchange) {
216 this.onchange = onchange;
217 }
218
219 public void setInline(String inline) {
220 this.inline = inline;
221 }
222
223 public void setReadonly(String readonly) {
224 this.readonly = readonly;
225 }
226
227 public void setDisabled(String disabled) {
228 this.disabled = disabled;
229 }
230
231 public void setRequired(String required) {
232 this.required = required;
233 }
234
235 public void setTip(String tip) {
236 this.tip = tip;
237 }
238
239 public void setLabelWidth(String labelWidth) {
240 this.labelWidth = labelWidth;
241 }
242
243 public void setTabIndex(String tabIndex) {
244 this.tabIndex = tabIndex;
245 }
246 }