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.Tag; 021 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag; 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.HasTip; 027 import org.apache.myfaces.tobago.taglib.decl.HasValidator; 028 import org.apache.myfaces.tobago.taglib.decl.HasValue; 029 import org.apache.myfaces.tobago.taglib.decl.IsDisabled; 030 import org.apache.myfaces.tobago.taglib.decl.IsFocus; 031 import org.apache.myfaces.tobago.taglib.decl.IsInline; 032 import org.apache.myfaces.tobago.taglib.decl.IsReadonly; 033 import org.apache.myfaces.tobago.taglib.decl.IsRequired; 034 import org.apache.myfaces.tobago.taglib.decl.HasOnchange; 035 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener; 036 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth; 037 038 import javax.servlet.jsp.JspException; 039 import javax.servlet.jsp.tagext.BodyTagSupport; 040 041 /* 042 * Created by IntelliJ IDEA. 043 * User: bommel 044 * Date: 18.12.2005 045 * Time: 23:25:21 046 */ 047 /** 048 * Renders a time input field with a label. 049 * <br> 050 * Short syntax of: 051 * 052 * <pre> 053 * <tc:panel> 054 * <f:facet name="layout"> 055 * <tc:gridLayout columns="fixed;*"/> 056 * </f:facet> 057 * <tc:label value="#{label}" for="@auto"/> 058 * <tc:time value="#{value}"> 059 * ... 060 * </tc:in> 061 * </tc:panel> 062 * </pre> 063 */ 064 @Tag(name = "time") 065 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.TimeTag") 066 public class TimeExtensionTag extends BodyTagSupport 067 implements HasValue, HasValueChangeListener, HasValidator, HasIdBindingAndRendered, 068 HasConverter, IsReadonly, IsDisabled, HasOnchange, 069 IsRequired, HasTip, HasLabel, HasLabelWidth, IsFocus, IsInline { 070 071 private String binding; 072 private String converter; 073 private String validator; 074 private String disabled; 075 private String focus; 076 private String label; 077 private String readonly; 078 private String rendered; 079 private String required; 080 private String tip; 081 private String value; 082 private String valueChangeListener; 083 private String inline; 084 private String onchange; 085 private String labelWidth; 086 087 private LabelExtensionTag labelTag; 088 private TimeTag timeTag; 089 090 @Override 091 public int doStartTag() throws JspException { 092 093 labelTag = new LabelExtensionTag(); 094 labelTag.setPageContext(pageContext); 095 if (label != null) { 096 labelTag.setValue(label); 097 } 098 if (tip != null) { 099 labelTag.setTip(tip); 100 } 101 if (rendered != null) { 102 labelTag.setRendered(rendered); 103 } 104 if (labelWidth != null) { 105 labelTag.setColumns(labelWidth + ";*"); 106 } 107 labelTag.setParent(getParent()); 108 labelTag.doStartTag(); 109 110 timeTag = new TimeTag(); 111 timeTag.setPageContext(pageContext); 112 if (value != null) { 113 timeTag.setValue(value); 114 } 115 if (valueChangeListener != null) { 116 timeTag.setValueChangeListener(valueChangeListener); 117 } 118 if (binding != null) { 119 timeTag.setBinding(binding); 120 } 121 if (converter != null) { 122 timeTag.setConverter(converter); 123 } 124 if (validator != null) { 125 timeTag.setValidator(validator); 126 } 127 if (onchange != null) { 128 timeTag.setOnchange(onchange); 129 } 130 if (disabled != null) { 131 timeTag.setDisabled(disabled); 132 } 133 if (focus != null) { 134 timeTag.setFocus(focus); 135 } 136 if (id != null) { 137 timeTag.setId(id); 138 } 139 if (inline != null) { 140 timeTag.setInline(inline); 141 } 142 if (readonly != null) { 143 timeTag.setReadonly(readonly); 144 } 145 if (required != null) { 146 timeTag.setRequired(required); 147 } 148 timeTag.setParent(labelTag); 149 timeTag.doStartTag(); 150 151 return super.doStartTag(); 152 } 153 154 @Override 155 public int doEndTag() throws JspException { 156 timeTag.doEndTag(); 157 labelTag.doEndTag(); 158 return super.doEndTag(); 159 } 160 161 @Override 162 public void release() { 163 super.release(); 164 binding = null; 165 converter = null; 166 validator = null; 167 disabled = null; 168 labelWidth = null; 169 focus = null; 170 label = null; 171 inline = null; 172 readonly = null; 173 rendered = null; 174 required = null; 175 tip = null; 176 value = null; 177 onchange = null; 178 valueChangeListener = 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 public void setLabelWidth(String labelWidth) { 239 this.labelWidth = labelWidth; 240 } 241 }