1 16 package org.apache.myfaces.custom.datascroller; 17 18 import org.apache.myfaces.component.html.ext.HtmlPanelGroup; 19 20 import javax.faces.component.UIComponent; 21 import javax.faces.context.FacesContext; 22 import javax.faces.el.ValueBinding; 23 24 28 public class HtmlDataScroller 29 extends HtmlPanelGroup 30 { 31 33 private static final String FIRST_FACET_NAME = "first"; 34 private static final String LAST_FACET_NAME = "last"; 35 private static final String NEXT_FACET_NAME = "next"; 36 private static final String PREVIOUS_FACET_NAME = "previous"; 37 private static final String FAST_FORWARD_FACET_NAME = "fastforward"; 38 private static final String FAST_REWIND_FACET_NAME = "fastrewind"; 39 40 public void setFirst(UIComponent first) 41 { 42 getFacets().put(FIRST_FACET_NAME, first); 43 } 44 45 public UIComponent getFirst() 46 { 47 return (UIComponent)getFacets().get(FIRST_FACET_NAME); 48 } 49 50 public void setLast(UIComponent last) 51 { 52 getFacets().put(LAST_FACET_NAME, last); 53 } 54 55 public UIComponent getLast() 56 { 57 return (UIComponent)getFacets().get(LAST_FACET_NAME); 58 } 59 60 public void setNext(UIComponent next) 61 { 62 getFacets().put(NEXT_FACET_NAME, next); 63 } 64 65 public UIComponent getNext() 66 { 67 return (UIComponent)getFacets().get(NEXT_FACET_NAME); 68 } 69 70 public void setFastForward(UIComponent previous) 71 { 72 getFacets().put(FAST_FORWARD_FACET_NAME, previous); 73 } 74 75 public UIComponent getFastForward() 76 { 77 return (UIComponent)getFacets().get(FAST_FORWARD_FACET_NAME); 78 } 79 80 public void setFastRewind(UIComponent previous) 81 { 82 getFacets().put(FAST_REWIND_FACET_NAME, previous); 83 } 84 85 public UIComponent getFastRewind() 86 { 87 return (UIComponent)getFacets().get(FAST_REWIND_FACET_NAME); 88 } 89 90 public void setPrevoius(UIComponent previous) 91 { 92 getFacets().put(PREVIOUS_FACET_NAME, previous); 93 } 94 95 public UIComponent getPrevious() 96 { 97 return (UIComponent)getFacets().get(PREVIOUS_FACET_NAME); 98 } 99 100 101 public boolean getRendersChildren() 102 { 103 return true; 104 } 105 106 107 109 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlDataScroller"; 110 public static final String COMPONENT_FAMILY = "javax.faces.Panel"; 111 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.DataScroller"; 112 113 private String _for = null; 114 private Integer _fastStep = null; 115 private String _pageIndexVar = null; 116 private String _pageCountVar = null; 117 private String _rowsCountVar = null; 118 private String _displayedRowsCountVar = null; 119 private String _firstRowIndexVar = null; 120 private String _lastRowIndexVar = null; 121 private String _style = null; 122 private String _styleClass = null; 123 private String _columnClasses = null; 124 private Boolean _paginator = null; 125 private Integer _paginatorMaxPages = null; 126 private String _paginatorTableClass = null; 127 private String _paginatorTableStyle = null; 128 private String _paginatorColumnClass = null; 129 private String _paginatorColumnStyle = null; 130 private String _paginatorActiveColumnClass = null; 131 private String _paginatorActiveColumnStyle = null; 132 133 public HtmlDataScroller() 134 { 135 setRendererType(DEFAULT_RENDERER_TYPE); 136 } 137 138 public String getFamily() 139 { 140 return COMPONENT_FAMILY; 141 } 142 143 public void setFor(String forValue) 144 { 145 _for = forValue; 146 } 147 148 public String getFor() 149 { 150 if (_for != null) return _for; 151 ValueBinding vb = getValueBinding("for"); 152 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 153 } 154 155 public void setFastStep(int fastStep) 156 { 157 _fastStep = new Integer (fastStep); 158 } 159 160 public int getFastStep() 161 { 162 if (_fastStep != null) return _fastStep.intValue(); 163 ValueBinding vb = getValueBinding("fastStep"); 164 Integer v = vb != null ? (Integer )vb.getValue(getFacesContext()) : null; 165 return v != null ? v.intValue() : Integer.MIN_VALUE; 166 } 167 168 public void setPageIndexVar(String pageIndexVar) 169 { 170 _pageIndexVar = pageIndexVar; 171 } 172 173 public String getPageIndexVar() 174 { 175 if (_pageIndexVar != null) return _pageIndexVar; 176 ValueBinding vb = getValueBinding("pageIndexVar"); 177 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 178 } 179 180 public void setPageCountVar(String pageCountVar) 181 { 182 _pageCountVar = pageCountVar; 183 } 184 185 public String getPageCountVar() 186 { 187 if (_pageCountVar != null) return _pageCountVar; 188 ValueBinding vb = getValueBinding("pageCountVar"); 189 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 190 } 191 192 public void setRowsCountVar(String rowsCountVar) 193 { 194 _rowsCountVar = rowsCountVar; 195 } 196 197 public String getRowsCountVar() 198 { 199 if (_rowsCountVar != null) return _rowsCountVar; 200 ValueBinding vb = getValueBinding("rowsCountVar"); 201 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 202 } 203 204 public void setDisplayedRowsCountVar(String displayedRowsCountVar) 205 { 206 _displayedRowsCountVar = displayedRowsCountVar; 207 } 208 209 public String getDisplayedRowsCountVar() 210 { 211 if (_displayedRowsCountVar != null) return _displayedRowsCountVar; 212 ValueBinding vb = getValueBinding("displayedRowsCountVar"); 213 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 214 } 215 216 public void setFirstRowIndexVar(String firstRowIndexVar) 217 { 218 _firstRowIndexVar = firstRowIndexVar; 219 } 220 221 public String getFirstRowIndexVar() 222 { 223 if (_firstRowIndexVar != null) return _firstRowIndexVar; 224 ValueBinding vb = getValueBinding("firstRowIndexVar"); 225 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 226 } 227 228 public void setLastRowIndexVar(String lastRowIndexVar) 229 { 230 _lastRowIndexVar = lastRowIndexVar; 231 } 232 233 public String getLastRowIndexVar() 234 { 235 if (_lastRowIndexVar != null) return _lastRowIndexVar; 236 ValueBinding vb = getValueBinding("lastRowIndexVar"); 237 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 238 } 239 240 public void setStyle(String style) 241 { 242 _style = style; 243 } 244 245 public String getStyle() 246 { 247 if (_style != null) return _style; 248 ValueBinding vb = getValueBinding("style"); 249 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 250 } 251 252 public void setStyleClass(String styleClass) 253 { 254 _styleClass = styleClass; 255 } 256 257 public String getStyleClass() 258 { 259 if (_styleClass != null) return _styleClass; 260 ValueBinding vb = getValueBinding("styleClass"); 261 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 262 } 263 264 public void setPaginator(boolean paginator) 265 { 266 _paginator = Boolean.valueOf(paginator); 267 } 268 269 public boolean isPaginator() 270 { 271 if (_paginator != null) return _paginator.booleanValue(); 272 ValueBinding vb = getValueBinding("paginator"); 273 Boolean v = vb != null ? (Boolean )vb.getValue(getFacesContext()) : null; 274 return v != null ? v.booleanValue() : false; 275 } 276 277 public void setPaginatorMaxPages(int paginatorMaxPages) 278 { 279 _paginatorMaxPages = new Integer (paginatorMaxPages); 280 } 281 282 public int getPaginatorMaxPages() 283 { 284 if (_paginatorMaxPages != null) return _paginatorMaxPages.intValue(); 285 ValueBinding vb = getValueBinding("paginatorMaxPages"); 286 Integer v = vb != null ? (Integer )vb.getValue(getFacesContext()) : null; 287 return v != null ? v.intValue() : Integer.MIN_VALUE; 288 } 289 290 public void setPaginatorTableClass(String paginatorTableClass) 291 { 292 _paginatorTableClass = paginatorTableClass; 293 } 294 295 public String getPaginatorTableClass() 296 { 297 if (_paginatorTableClass != null) return _paginatorTableClass; 298 ValueBinding vb = getValueBinding("paginatorTableClass"); 299 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 300 } 301 302 public void setPaginatorTableStyle(String paginatorTableStyle) 303 { 304 _paginatorTableStyle = paginatorTableStyle; 305 } 306 307 public String getPaginatorTableStyle() 308 { 309 if (_paginatorTableStyle != null) return _paginatorTableStyle; 310 ValueBinding vb = getValueBinding("paginatorTableStyle"); 311 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 312 } 313 314 public void setPaginatorColumnClass(String paginatorColumnClass) 315 { 316 _paginatorColumnClass = paginatorColumnClass; 317 } 318 319 public String getPaginatorColumnClass() 320 { 321 if (_paginatorColumnClass != null) return _paginatorColumnClass; 322 ValueBinding vb = getValueBinding("paginatorColumnClass"); 323 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 324 } 325 326 public void setPaginatorColumnStyle(String paginatorColumnStyle) 327 { 328 _paginatorColumnStyle = paginatorColumnStyle; 329 } 330 331 public String getPaginatorColumnStyle() 332 { 333 if (_paginatorColumnStyle != null) return _paginatorColumnStyle; 334 ValueBinding vb = getValueBinding("paginatorColumnStyle"); 335 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 336 } 337 338 public void setPaginatorActiveColumnClass(String paginatorActiveColumnClass) 339 { 340 _paginatorActiveColumnClass = paginatorActiveColumnClass; 341 } 342 343 public String getPaginatorActiveColumnClass() 344 { 345 if (_paginatorActiveColumnClass != null) return _paginatorActiveColumnClass; 346 ValueBinding vb = getValueBinding("paginatorActiveColumnClass"); 347 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 348 } 349 350 public void setPaginatorActiveColumnStyle(String paginatorActiveColumnStyle) 351 { 352 _paginatorActiveColumnStyle = paginatorActiveColumnStyle; 353 } 354 355 public String getPaginatorActiveColumnStyle() 356 { 357 if (_paginatorActiveColumnStyle != null) return _paginatorActiveColumnStyle; 358 ValueBinding vb = getValueBinding("paginatorActiveColumnStyle"); 359 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 360 } 361 362 363 364 public Object saveState(FacesContext context) 365 { 366 Object values[] = new Object [20]; 367 values[0] = super.saveState(context); 368 values[1] = _for; 369 values[2] = _fastStep; 370 values[3] = _pageIndexVar; 371 values[4] = _pageCountVar; 372 values[5] = _rowsCountVar; 373 values[6] = _displayedRowsCountVar; 374 values[7] = _firstRowIndexVar; 375 values[8] = _lastRowIndexVar; 376 values[9] = _style; 377 values[10] = _styleClass; 378 values[11] = _columnClasses; 379 values[12] = _paginator; 380 values[13] = _paginatorMaxPages; 381 values[14] = _paginatorTableClass; 382 values[15] = _paginatorTableStyle; 383 values[16] = _paginatorColumnClass; 384 values[17] = _paginatorColumnStyle; 385 values[18] = _paginatorActiveColumnClass; 386 values[19] = _paginatorActiveColumnStyle; 387 return values; 388 } 389 390 public void restoreState(FacesContext context, Object state) 391 { 392 Object values[] = (Object [])state; 393 super.restoreState(context, values[0]); 394 _for = (String )values[1]; 395 _fastStep = (Integer )values[2]; 396 _pageIndexVar = (String )values[3]; 397 _pageCountVar = (String )values[4]; 398 _rowsCountVar = (String )values[5]; 399 _displayedRowsCountVar = (String )values[6]; 400 _firstRowIndexVar = (String )values[7]; 401 _lastRowIndexVar = (String )values[8]; 402 _style = (String )values[9]; 403 _styleClass = (String )values[10]; 404 _columnClasses = (String )values[11]; 405 _paginator = (Boolean )values[12]; 406 _paginatorMaxPages = (Integer )values[13]; 407 _paginatorTableClass = (String )values[14]; 408 _paginatorTableStyle = (String )values[15]; 409 _paginatorColumnClass = (String )values[16]; 410 _paginatorColumnStyle = (String )values[17]; 411 _paginatorActiveColumnClass = (String )values[18]; 412 _paginatorActiveColumnStyle = (String )values[19]; 413 } 414 } 416 | Popular Tags |