1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.myfaces.custom.calendar; 20 21 import org.apache.myfaces.component.AlignProperty; 22 import org.apache.myfaces.component.LocationAware; 23 import org.apache.myfaces.component.UserRoleAware; 24 import org.apache.myfaces.component.UserRoleUtils; 25 import org.apache.myfaces.component.html.ext.HtmlInputText; 26 27 /** 28 * <p> 29 * Provides a calendar. The calendar can be "inline", or a button can be rendered 30 * that displays the calendar in a "popup window" when clicked. Javascript is 31 * required for the popup window. 32 * </p> 33 * <p> 34 * The two forms of calendar are unfortunately not well integrated; this component is 35 * effectively two components that happen to use the same component class. Some 36 * attributes on the component are applicable only to the inline form while others 37 * are applicable only to the popup form. 38 * </p> 39 * <p> 40 * The appearance of the inline calendar can be controlled via attributes 41 * such as currentDayCellClass, dayCellClass, weekRowClass, monthYearRowClass. 42 * Attributes "styleLocation", "javascriptLocation", "imageLocation" and all 43 * attributes starting with "popup" have no effect on an inline calendar. 44 * </p> 45 * <ul> 46 * <p> 47 * The appearance of the popup calendar can be controlled via attributes 48 * popupTheme, styleLocation, javascriptLocation and imageLocation: 49 * </p> 50 * <li>popupTheme: When styleLocation is not overridden then this selects one of the 51 * built-in themes ("WH" or "DB"); the default is "DB". This also selects the prefix 52 * used for the names of style classes attached to generated dom elements; all style 53 * names are of form "jscalendar-{popupTheme}-*". 54 * </li> 55 * <li>styleLocation: specifies the URL of a directory in which a "theme.css" file exists. 56 * A reference to this theme.css file will automatically be output. Specifying "none" as the 57 * location prevents the generation of this stylesheet reference; it is assumed that the 58 * necessary style rules will be loaded via some other mechanism. Defaults to a reference 59 * to a location within the tomahawk jarfile which varies based on popupTheme.</li> 60 * <li>javascriptLocation: specifies the URL of a directory in which all the necessary script 61 * files can be found. A reference to scripts "prototype.js", "date.js" and "popcalendar.js" 62 * will automatically be output. Specifying "none" prevents generation of these references; 63 * it is assumed that the necessary javascript functions will be loaded via some other 64 * mechanism. Defaults to a reference to a location within the tomahawk jarfile.</li> 65 * <li>imageLocation: specifies the URL of a directory in which all the necessary icons are 66 * defined. Defaults to a reference to a location within the tomahawk jarfile which 67 * varies depending on popupTheme.</li> 68 * </ul> 69 * Other styling attributes (eg dayCellClass, weekRowClass) are ignored for the popup calendar. 70 * <p> 71 * Unless otherwise specified, all attributes accept static values or EL expressions. 72 * </p> 73 * 74 * @JSFComponent 75 * name = "t:inputCalendar" 76 * class = "org.apache.myfaces.custom.calendar.HtmlInputCalendar" 77 * tagClass = "org.apache.myfaces.custom.calendar.HtmlInputCalendarTag" 78 * tagSuperclass = "org.apache.myfaces.custom.calendar.AbstractHtmlInputCalendarTag" 79 * tagHandler = "org.apache.myfaces.custom.calendar.HtmlInputCalendarTagHandler" 80 * @since 1.1.7 81 * @author Martin Marinschek (latest modification by $Author: lu4242 $) 82 * @version $Revision: 990311 $ $Date: 2010-08-27 21:04:55 -0500 (Fri, 27 Aug 2010) $ 83 */ 84 public abstract class AbstractHtmlInputCalendar 85 extends HtmlInputText implements UserRoleAware, LocationAware, 86 AlignProperty 87 { 88 89 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlInputCalendar"; 90 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Calendar"; 91 92 public boolean isRendered() 93 { 94 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 95 return super.isRendered(); 96 } 97 98 /** 99 * Indicate an object used as a bridge between the java.util.Date instance 100 * used by this component internally and the value object used on the bean, 101 * referred as a "business" value. 102 * 103 * <ul> 104 * <li>If the value is literal, look for the mentioned class instance, 105 * create a new instance and assign to the component property.</li> 106 * <li>If it the value a EL Expression, set the expression to the 107 * component property.</li> 108 * </ul> 109 * 110 * @JSFProperty stateHolder="true" inheritedTag="true" 111 */ 112 public abstract DateBusinessConverter getDateBusinessConverter(); 113 114 public abstract void setDateBusinessConverter(DateBusinessConverter dateBusinessConverter); 115 116 /** 117 * CSS class to be used on the TR element for the header-row showing month and year. 118 * 119 * @JSFProperty 120 */ 121 public abstract String getMonthYearRowClass(); 122 123 /** 124 * CSS class to be used on the TR element for the header-row showing the week-days. 125 * 126 * @JSFProperty 127 */ 128 public abstract String getWeekRowClass(); 129 130 /** 131 * CSS class to be used for the TD element containing a day days. 132 * 133 * @JSFProperty 134 */ 135 public abstract String getDayCellClass(); 136 137 /** 138 * CSS class to be used for the TD element of the currently selected date. 139 * 140 * @JSFProperty 141 */ 142 public abstract String getCurrentDayCellClass(); 143 144 /** 145 * Render the input-calendar left of the button, not right like normally done. 146 * 147 * @JSFProperty 148 * defaultValue = "false" 149 */ 150 public abstract boolean isPopupLeft(); 151 152 /** 153 * Render the input-calendar as a java-script popup on client. 154 * 155 * @JSFProperty 156 * defaultValue = false; 157 */ 158 public abstract boolean isRenderAsPopup(); 159 160 /** 161 * Automatically add the input-calendar scripts and css files to 162 * the header - set that to false to provide the scripts yourself. 163 * 164 * @JSFProperty 165 * defaultValue = "true" 166 */ 167 public abstract boolean isAddResources(); 168 169 public abstract void setAddResources(boolean value); 170 171 public void setAddResources(Boolean value) 172 { 173 this.setAddResources(value.booleanValue()); 174 } 175 176 /** 177 * Defines the string displayed on the button which leads to 178 * the calendar-popup-window (... by default). 179 * 180 * @JSFProperty 181 */ 182 public abstract String getPopupButtonString(); 183 184 /** 185 * Defines the css style for the button which leads to the 186 * calendar-popup-window. 187 * 188 * @JSFProperty 189 */ 190 public abstract String getPopupButtonStyle(); 191 192 /** 193 * Defines the css style class for the button which leads to the 194 * calendar-popup-window. 195 * 196 * @JSFProperty 197 */ 198 public abstract String getPopupButtonStyleClass(); 199 200 /** 201 * If true, renders a calendar icon instead of the button to pop up the calendar. 202 * 203 * @JSFProperty 204 * defaultValue = "false" 205 */ 206 public abstract boolean isRenderPopupButtonAsImage(); 207 208 /** 209 * Defines the date format used by the java-script popup on client. 210 * 211 * @JSFProperty 212 */ 213 public abstract String getPopupDateFormat(); 214 215 /** 216 * Set the string for "Go To Current Month" 217 * 218 * @JSFProperty 219 */ 220 public abstract String getPopupGotoString(); 221 222 /** 223 * Set the string for "Today is" 224 * 225 * @JSFProperty 226 */ 227 public abstract String getPopupTodayString(); 228 229 /** 230 * Defines the date format used by the java-script popup 231 * on client for the today-is string. 232 * 233 * @JSFProperty 234 */ 235 public abstract String getPopupTodayDateFormat(); 236 237 /** 238 * Set the string for "Wk" 239 * 240 * @JSFProperty 241 */ 242 public abstract String getPopupWeekString(); 243 244 /** 245 * Set the string for scrolling to the left. 246 * 247 * @JSFProperty 248 */ 249 public abstract String getPopupScrollLeftMessage(); 250 251 /** 252 * Set the string for scrolling to the right. 253 * 254 * @JSFProperty 255 */ 256 public abstract String getPopupScrollRightMessage(); 257 258 /** 259 * Set the string for "Click to select a month". 260 * 261 * @JSFProperty 262 */ 263 public abstract String getPopupSelectMonthMessage(); 264 265 /** 266 * Set the string for "Click to select a year". 267 * 268 * @JSFProperty 269 */ 270 public abstract String getPopupSelectYearMessage(); 271 272 /** 273 * Set the string for "Select [date] as date" (do not 274 * replace [date], it will be replaced by the current date). 275 * 276 * @JSFProperty 277 */ 278 public abstract String getPopupSelectDateMessage(); 279 280 /** 281 * Set the theme-prefix for this component. 282 * 283 * @JSFProperty 284 */ 285 public abstract String getPopupTheme(); 286 287 /** 288 * Url to the image for this popupButton. 289 * 290 * @JSFProperty 291 */ 292 public abstract String getPopupButtonImageUrl(); 293 294 /** 295 * The text that will be rendered in the field - helping the 296 * user to find the right format to enter into the field. 297 * 298 * @JSFProperty 299 */ 300 public abstract String getHelpText(); 301 302 303 /** 304 * <p> 305 * May be "day", "week", "month" or "none": 306 * <ul> 307 * <li>day (default): allow the user to select a day.</li> 308 * <li>week: only allow the user to select a week.</li> 309 * <li>month: only allow the user to select a month.</li> 310 * <li>none: equivalent to "readonly".</li> 311 * </ul> 312 * </p> 313 * 314 * @JSFProperty 315 * defaultValue = "day" 316 */ 317 public abstract String getPopupSelectMode(); 318 }