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