1 16 package org.apache.myfaces.custom.calendar; 17 18 import org.apache.myfaces.component.UserRoleUtils; 19 20 import javax.faces.component.html.HtmlInputText; 21 import javax.faces.context.FacesContext; 22 import javax.faces.el.ValueBinding; 23 24 28 public class HtmlInputCalendar 29 extends HtmlInputText 30 { 31 33 35 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlInputCalendar"; 36 public static final String COMPONENT_FAMILY = "javax.faces.Input"; 37 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Calendar"; 38 39 private String _monthYearRowClass = null; 40 private String _weekRowClass = null; 41 private String _dayCellClass = null; 42 private String _currentDayCellClass = null; 43 private Boolean _renderAsPopup = null; 44 private Boolean _addResources = null; 45 private String _popupButtonString = null; 46 private String _popupDateFormat = null; 47 private String _enabledOnUserRole = null; 48 private String _visibleOnUserRole = null; 49 private String _popupGotoString = null; 50 private String _popupTodayString = null; 51 private String _popupWeekString = null; 52 private String _popupScrollLeftMessage = null; 53 private String _popupScrollRightMessage = null; 54 private String _popupSelectMonthMessage = null; 55 private String _popupSelectYearMessage = null; 56 private String _popupSelectDateMessage = null; 57 58 public HtmlInputCalendar() 59 { 60 setRendererType(DEFAULT_RENDERER_TYPE); 61 } 62 63 public String getFamily() 64 { 65 return COMPONENT_FAMILY; 66 } 67 68 public void setMonthYearRowClass(String monthYearRowClass) 69 { 70 _monthYearRowClass = monthYearRowClass; 71 } 72 73 public String getMonthYearRowClass() 74 { 75 if (_monthYearRowClass != null) return _monthYearRowClass; 76 ValueBinding vb = getValueBinding("monthYearRowClass"); 77 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 78 } 79 80 public void setWeekRowClass(String weekRowClass) 81 { 82 _weekRowClass = weekRowClass; 83 } 84 85 public String getWeekRowClass() 86 { 87 if (_weekRowClass != null) return _weekRowClass; 88 ValueBinding vb = getValueBinding("weekRowClass"); 89 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 90 } 91 92 public void setDayCellClass(String dayCellClass) 93 { 94 _dayCellClass = dayCellClass; 95 } 96 97 public String getDayCellClass() 98 { 99 if (_dayCellClass != null) return _dayCellClass; 100 ValueBinding vb = getValueBinding("dayCellClass"); 101 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 102 } 103 104 public void setCurrentDayCellClass(String currentDayCellClass) 105 { 106 _currentDayCellClass = currentDayCellClass; 107 } 108 109 public String getCurrentDayCellClass() 110 { 111 if (_currentDayCellClass != null) return _currentDayCellClass; 112 ValueBinding vb = getValueBinding("currentDayCellClass"); 113 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 114 } 115 116 public void setRenderAsPopup(boolean renderAsPopup) 117 { 118 _renderAsPopup = Boolean.valueOf(renderAsPopup); 119 } 120 121 public boolean isRenderAsPopup() 122 { 123 if (_renderAsPopup != null) return _renderAsPopup.booleanValue(); 124 ValueBinding vb = getValueBinding("renderAsPopup"); 125 Boolean v = vb != null ? (Boolean )vb.getValue(getFacesContext()) : null; 126 return v != null ? v.booleanValue() : false; 127 } 128 129 public void setAddResources(boolean addResources) 130 { 131 _addResources = Boolean.valueOf(addResources); 132 } 133 134 public boolean isAddResources() 135 { 136 if (_addResources != null) return _addResources.booleanValue(); 137 ValueBinding vb = getValueBinding("addResources"); 138 Boolean v = vb != null ? (Boolean )vb.getValue(getFacesContext()) : null; 139 return v != null ? v.booleanValue() : false; 140 } 141 142 public void setPopupButtonString(String popupButtonString) 143 { 144 _popupButtonString = popupButtonString; 145 } 146 147 public String getPopupButtonString() 148 { 149 if (_popupButtonString != null) return _popupButtonString; 150 ValueBinding vb = getValueBinding("popupButtonString"); 151 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 152 } 153 154 public void setPopupDateFormat(String popupDateFormat) 155 { 156 _popupDateFormat = popupDateFormat; 157 } 158 159 public String getPopupDateFormat() 160 { 161 if (_popupDateFormat != null) return _popupDateFormat; 162 ValueBinding vb = getValueBinding("popupDateFormat"); 163 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 164 } 165 166 public void setEnabledOnUserRole(String enabledOnUserRole) 167 { 168 _enabledOnUserRole = enabledOnUserRole; 169 } 170 171 public String getEnabledOnUserRole() 172 { 173 if (_enabledOnUserRole != null) return _enabledOnUserRole; 174 ValueBinding vb = getValueBinding("enabledOnUserRole"); 175 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 176 } 177 178 public void setVisibleOnUserRole(String visibleOnUserRole) 179 { 180 _visibleOnUserRole = visibleOnUserRole; 181 } 182 183 public String getVisibleOnUserRole() 184 { 185 if (_visibleOnUserRole != null) return _visibleOnUserRole; 186 ValueBinding vb = getValueBinding("visibleOnUserRole"); 187 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 188 } 189 190 public void setPopupGotoString(String popupGotoString) 191 { 192 _popupGotoString = popupGotoString; 193 } 194 195 public String getPopupGotoString() 196 { 197 if (_popupGotoString != null) return _popupGotoString; 198 ValueBinding vb = getValueBinding("popupGotoString"); 199 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 200 } 201 202 public void setPopupTodayString(String popupTodayString) 203 { 204 _popupTodayString = popupTodayString; 205 } 206 207 public String getPopupTodayString() 208 { 209 if (_popupTodayString != null) return _popupTodayString; 210 ValueBinding vb = getValueBinding("popupTodayString"); 211 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 212 } 213 214 public void setPopupWeekString(String popupWeekString) 215 { 216 _popupWeekString = popupWeekString; 217 } 218 219 public String getPopupWeekString() 220 { 221 if (_popupWeekString != null) return _popupWeekString; 222 ValueBinding vb = getValueBinding("popupWeekString"); 223 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 224 } 225 226 public void setPopupScrollLeftMessage(String popupScrollLeftMessage) 227 { 228 _popupScrollLeftMessage = popupScrollLeftMessage; 229 } 230 231 public String getPopupScrollLeftMessage() 232 { 233 if (_popupScrollLeftMessage != null) return _popupScrollLeftMessage; 234 ValueBinding vb = getValueBinding("popupScrollLeftMessage"); 235 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 236 } 237 238 public void setPopupScrollRightMessage(String popupScrollRightMessage) 239 { 240 _popupScrollRightMessage = popupScrollRightMessage; 241 } 242 243 public String getPopupScrollRightMessage() 244 { 245 if (_popupScrollRightMessage != null) return _popupScrollRightMessage; 246 ValueBinding vb = getValueBinding("popupScrollRightMessage"); 247 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 248 } 249 250 public void setPopupSelectMonthMessage(String popupSelectMonthMessage) 251 { 252 _popupSelectMonthMessage = popupSelectMonthMessage; 253 } 254 255 public String getPopupSelectMonthMessage() 256 { 257 if (_popupSelectMonthMessage != null) return _popupSelectMonthMessage; 258 ValueBinding vb = getValueBinding("popupSelectMonthMessage"); 259 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 260 } 261 262 public void setPopupSelectYearMessage(String popupSelectYearMessage) 263 { 264 _popupSelectYearMessage = popupSelectYearMessage; 265 } 266 267 public String getPopupSelectYearMessage() 268 { 269 if (_popupSelectYearMessage != null) return _popupSelectYearMessage; 270 ValueBinding vb = getValueBinding("popupSelectYearMessage"); 271 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 272 } 273 274 public void setPopupSelectDateMessage(String popupSelectDateMessage) 275 { 276 _popupSelectDateMessage = popupSelectDateMessage; 277 } 278 279 public String getPopupSelectDateMessage() 280 { 281 if (_popupSelectDateMessage != null) return _popupSelectDateMessage; 282 ValueBinding vb = getValueBinding("popupSelectDateMessage"); 283 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 284 } 285 286 287 public boolean isRendered() 288 { 289 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 290 return super.isRendered(); 291 } 292 293 public Object saveState(FacesContext context) 294 { 295 Object values[] = new Object [19]; 296 values[0] = super.saveState(context); 297 values[1] = _monthYearRowClass; 298 values[2] = _weekRowClass; 299 values[3] = _dayCellClass; 300 values[4] = _currentDayCellClass; 301 values[5] = _renderAsPopup; 302 values[6] = _addResources; 303 values[7] = _popupButtonString; 304 values[8] = _popupDateFormat; 305 values[9] = _enabledOnUserRole; 306 values[10] = _visibleOnUserRole; 307 values[11] = _popupGotoString; 308 values[12] = _popupTodayString; 309 values[13] = _popupWeekString; 310 values[14] = _popupScrollLeftMessage; 311 values[15] = _popupScrollRightMessage; 312 values[16] = _popupSelectMonthMessage; 313 values[17] = _popupSelectYearMessage; 314 values[18] = _popupSelectDateMessage; 315 return ((Object ) (values)); 316 } 317 318 public void restoreState(FacesContext context, Object state) 319 { 320 Object values[] = (Object [])state; 321 super.restoreState(context, values[0]); 322 _monthYearRowClass = (String )values[1]; 323 _weekRowClass = (String )values[2]; 324 _dayCellClass = (String )values[3]; 325 _currentDayCellClass = (String )values[4]; 326 _renderAsPopup = (Boolean )values[5]; 327 _addResources = (Boolean )values[6]; 328 _popupButtonString = (String )values[7]; 329 _popupDateFormat = (String )values[8]; 330 _enabledOnUserRole = (String )values[9]; 331 _visibleOnUserRole = (String )values[10]; 332 _popupGotoString = (String )values[11]; 333 _popupTodayString = (String )values[12]; 334 _popupWeekString = (String )values[13]; 335 _popupScrollLeftMessage = (String )values[14]; 336 _popupScrollRightMessage = (String )values[15]; 337 _popupSelectMonthMessage = (String )values[16]; 338 _popupSelectYearMessage = (String )values[17]; 339 _popupSelectDateMessage = (String )values[18]; 340 } 341 } 343 | Popular Tags |