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 * Created by IntelliJ IDEA. 044 * User: bommel 045 * Date: 18.12.2005 046 * Time: 23:25:21 047 */ 048 /** 049 * Renders a time input field with a label. 050 * <br /> 051 * Short syntax of: 052 * 053 * <pre> 054 * <tc:panel> 055 * <f:facet name="layout"> 056 * <tc:gridLayout columns="fixed;*"/> 057 * </f:facet> 058 * <tc:label value="#{label}" for="@auto"/> 059 * <tc:time value="#{value}"> 060 * ... 061 * </tc:in> 062 * </tc:panel> 063 * </pre> 064 */ 065 @Tag(name = "time") 066 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.TimeTag") 067 public class TimeExtensionTag extends BodyTagSupport 068 implements HasValue, HasValueChangeListener, HasValidator, HasIdBindingAndRendered, 069 HasConverter, IsReadonly, IsDisabled, HasOnchange, IsRequired, HasTip, 070 HasLabel, HasLabelWidth, IsFocus, IsInline, HasTabIndex { 071 072 private String binding; 073 private String converter; 074 private String validator; 075 private String disabled; 076 private String focus; 077 private String label; 078 private String readonly; 079 private String rendered; 080 private String required; 081 private String tip; 082 private String value; 083 private String valueChangeListener; 084 private String inline; 085 private String onchange; 086 private String labelWidth; 087 private String tabIndex; 088 089 private LabelExtensionTag labelTag; 090 private TimeTag timeTag; 091 092 @Override 093 public int doStartTag() throws JspException { 094 095 labelTag = new LabelExtensionTag(); 096 labelTag.setPageContext(pageContext); 097 if (label != null) { 098 labelTag.setValue(label); 099 } 100 if (tip != null) { 101 labelTag.setTip(tip); 102 } 103 if (rendered != null) { 104 labelTag.setRendered(rendered); 105 } 106 if (labelWidth != null) { 107 labelTag.setColumns(labelWidth + ";*"); 108 } 109 labelTag.setParent(getParent()); 110 labelTag.doStartTag(); 111 112 timeTag = new TimeTag(); 113 timeTag.setPageContext(pageContext); 114 if (value != null) { 115 timeTag.setValue(value); 116 } 117 if (valueChangeListener != null) { 118 timeTag.setValueChangeListener(valueChangeListener); 119 } 120 if (binding != null) { 121 timeTag.setBinding(binding); 122 } 123 if (converter != null) { 124 timeTag.setConverter(converter); 125 } 126 if (validator != null) { 127 timeTag.setValidator(validator); 128 } 129 if (onchange != null) { 130 timeTag.setOnchange(onchange); 131 } 132 if (disabled != null) { 133 timeTag.setDisabled(disabled); 134 } 135 if (focus != null) { 136 timeTag.setFocus(focus); 137 } 138 if (id != null) { 139 timeTag.setId(id); 140 } 141 if (inline != null) { 142 timeTag.setInline(inline); 143 } 144 if (readonly != null) { 145 timeTag.setReadonly(readonly); 146 } 147 if (required != null) { 148 timeTag.setRequired(required); 149 } 150 if (tabIndex != null) { 151 timeTag.setTabIndex(tabIndex); 152 } 153 timeTag.setParent(labelTag); 154 timeTag.doStartTag(); 155 156 return super.doStartTag(); 157 } 158 159 @Override 160 public int doEndTag() throws JspException { 161 timeTag.doEndTag(); 162 labelTag.doEndTag(); 163 return super.doEndTag(); 164 } 165 166 @Override 167 public void release() { 168 super.release(); 169 binding = null; 170 converter = null; 171 validator = null; 172 disabled = null; 173 labelWidth = null; 174 focus = null; 175 label = null; 176 inline = null; 177 readonly = null; 178 rendered = null; 179 required = null; 180 tip = null; 181 value = null; 182 onchange = null; 183 valueChangeListener = null; 184 tabIndex = null; 185 timeTag = null; 186 labelTag = null; 187 } 188 189 public void setValue(String value) { 190 this.value = value; 191 } 192 193 public void setValueChangeListener(String valueChangeListener) { 194 this.valueChangeListener = valueChangeListener; 195 } 196 197 public void setLabel(String label) { 198 this.label = label; 199 } 200 201 public void setFocus(String focus) { 202 this.focus = focus; 203 } 204 205 public void setBinding(String binding) { 206 this.binding = binding; 207 } 208 209 public void setRendered(String rendered) { 210 this.rendered = rendered; 211 } 212 213 public void setConverter(String converter) { 214 this.converter = converter; 215 } 216 217 public void setValidator(String validator) { 218 this.validator = validator; 219 } 220 221 public void setOnchange(String onchange) { 222 this.onchange = onchange; 223 } 224 225 public void setInline(String inline) { 226 this.inline = inline; 227 } 228 229 public void setReadonly(String readonly) { 230 this.readonly = readonly; 231 } 232 233 public void setDisabled(String disabled) { 234 this.disabled = disabled; 235 } 236 237 public void setRequired(String required) { 238 this.required = required; 239 } 240 241 public void setTip(String tip) { 242 this.tip = tip; 243 } 244 245 public void setLabelWidth(String labelWidth) { 246 this.labelWidth = labelWidth; 247 } 248 249 public void setTabIndex(String tabIndex) { 250 this.tabIndex = tabIndex; 251 } 252 }