1 33 48 package com.icesoft.faces.component.datapaginator; 49 50 import com.icesoft.faces.component.CSS_DEFAULT; 51 import com.icesoft.faces.component.ext.taglib.Util; 52 import com.icesoft.faces.application.D2DViewHandler; 53 import org.apache.commons.logging.Log; 54 import org.apache.commons.logging.LogFactory; 55 56 import javax.faces.component.ActionSource; 57 import javax.faces.component.UIComponent; 58 import javax.faces.component.UIData; 59 import javax.faces.component.html.HtmlPanelGroup; 60 import javax.faces.context.FacesContext; 61 import javax.faces.el.EvaluationException; 62 import javax.faces.el.MethodBinding; 63 import javax.faces.el.ValueBinding; 64 import javax.faces.event.AbortProcessingException; 65 import javax.faces.event.ActionEvent; 66 import javax.faces.event.ActionListener; 67 import javax.faces.event.FacesEvent; 68 import javax.faces.event.PhaseId; 69 import java.sql.ResultSet ; 70 71 72 75 public class DataPaginator extends HtmlPanelGroup implements ActionSource { 76 private final Log log = LogFactory.getLog(DataPaginator.class); 77 78 private static final String FIRST_FACET_NAME = "first"; 79 private static final String LAST_FACET_NAME = "last"; 80 private static final String NEXT_FACET_NAME = "next"; 81 private static final String PREVIOUS_FACET_NAME = "previous"; 82 private static final String FAST_FORWARD_FACET_NAME = "fastforward"; 83 private static final String FAST_REWIND_FACET_NAME = "fastrewind"; 84 85 private transient UIData _UIData; 87 88 private MethodBinding _actionListener; 89 private Boolean disabled = null; 90 91 94 public String getComponentType() { 95 return COMPONENT_TYPE; 96 } 97 98 102 public String getRendererType() { 103 return DEFAULT_RENDERER_TYPE; 104 } 105 106 109 public void setDisabled(boolean disabled) { 110 this.disabled = new Boolean (disabled); 111 ValueBinding vb = getValueBinding("disabled"); 112 if (vb != null) { 113 vb.setValue(getFacesContext(), this.disabled); 114 this.disabled = null; 115 } 116 } 117 118 121 public boolean isDisabled() { 122 if (!Util.isEnabledOnUserRole(this)) { 123 return true; 124 } 125 if (disabled != null) { 126 return disabled.booleanValue(); 127 } 128 ValueBinding vb = getValueBinding("disabled"); 129 Boolean v = 130 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 131 return v != null ? v.booleanValue() : false; 132 } 133 134 137 public void queueEvent(FacesEvent event) { 138 if (event != null && event instanceof ActionEvent) { 139 if (isImmediate()) { 140 event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES); 141 } else { 142 event.setPhaseId(PhaseId.INVOKE_APPLICATION); 143 } 144 } 145 super.queueEvent(event); 146 } 147 148 151 public void broadcast(FacesEvent event) throws AbortProcessingException { 152 super.broadcast(event); 153 154 if (event instanceof PaginatorActionEvent) { 155 PaginatorActionEvent scrollerEvent = (PaginatorActionEvent) event; 156 broadcastToActionListener(scrollerEvent); 157 UIData uiData = getUIData(); 158 if (uiData == null) { 159 return; 160 } 161 162 int pageindex = scrollerEvent.getPageIndex(); 163 if (pageindex == -1) { 164 String facet = scrollerEvent.getScrollerfacet(); 165 if (FACET_FIRST.equals(facet)) { 166 gotoFirstPage(); 167 } else if (FACET_PREVIOUS.equals(facet)) { 168 gotoPreviousPage(); 169 } else if (FACET_NEXT.equals(facet)) { 170 gotoNextPage(); 171 } else if (FACET_FAST_FORWARD.equals(facet)) { 172 gotoFastForward(); 173 } else if (FACET_FAST_REWIND.equals(facet)) { 174 gotoFastRewind(); 175 } else if (FACET_LAST.equals(facet)) { 176 gotoLastPage(); 177 } 178 } else { 179 int pageCount = getPageCount(); 180 if (pageindex > pageCount) { 181 pageindex = pageCount; 182 } else if (pageindex <= 0) { 183 pageindex = 1; 184 } 185 uiData.setFirst(uiData.getRows() * (pageindex - 1)); 186 } 187 } 188 } 189 190 protected void broadcastToActionListener(PaginatorActionEvent event) { 191 FacesContext context = getFacesContext(); 192 193 try { 194 MethodBinding actionListenerBinding = getActionListener(); 195 if (actionListenerBinding != null) { 196 actionListenerBinding.invoke(context, new Object []{event}); 197 } 198 } catch (EvaluationException e) { 206 Throwable cause = e.getCause(); 207 if (cause != null && 208 cause instanceof AbortProcessingException) { 209 throw(AbortProcessingException) cause; 210 } 211 throw e; 212 } 213 } 214 215 219 public UIData getUIData() { 220 if (_UIData == null) { 221 _UIData = findUIData(); 222 } 223 return _UIData; 224 } 225 226 public void setUIData(UIData uiData) { 227 _UIData = uiData; 228 } 229 230 231 234 public int getPageIndex() { 235 UIData uiData = getUIData(); 236 int rows = uiData.getRows(); 237 int pageCount = getPageCount(); 238 int pageIndex = 0; 239 if (rows > 0) { 240 pageIndex = uiData.getFirst() / rows + 1; 241 if (pageIndex > pageCount) { 245 pageIndex = pageCount; 246 int rowCount = uiData.getRowCount(); 247 int countOfRecordsOnFinalPage = rowCount % rows; 248 if (countOfRecordsOnFinalPage == 0) { 249 if (rowCount - rows >= 0) { 251 uiData.setFirst(rowCount - rows); 252 } else { 253 uiData.setFirst(0); 254 } 255 } else { 256 uiData.setFirst(rowCount - countOfRecordsOnFinalPage); 258 } 259 } 260 } else { 261 log.warn("DataTable " + 262 uiData.getClientId(FacesContext.getCurrentInstance()) 263 + " has invalid rows attribute."); 264 pageIndex = 0; 265 } 266 267 if (uiData.getFirst() % rows > 0) { 268 pageIndex++; 269 } 270 return pageIndex; 271 } 272 273 276 public int getPageCount() { 277 UIData uiData = getUIData(); 278 int rows = uiData.getRows(); 279 280 int pageCount; 281 if (rows > 0) { 282 pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows; 283 if (uiData.getRowCount() % rows > 0) { 284 pageCount++; 285 } 286 } else { 287 rows = 1; 288 pageCount = 1; 289 } 290 return pageCount; 291 } 292 293 296 public int getRowCount() { 297 return getUIData().getRowCount(); 298 } 299 300 303 public int getRows() { 304 return getUIData().getRows(); 305 } 306 307 310 public int getFirstRow() { 311 return getUIData().getFirst(); 312 } 313 314 318 protected UIData findUIData() { 319 String forStr = getFor(); 320 UIComponent forComp; 321 if (forStr == null) { 322 forComp = getParent(); 324 } else { 325 326 328 forComp = D2DViewHandler.findComponent(forStr, this); 329 } 330 if (forComp == null) { 331 throw new IllegalArgumentException ( 332 "could not find UIData referenced by attribute dataScroller@for = '" 333 + forStr + "'"); 334 } else if (!(forComp instanceof UIData)) { 335 throw new IllegalArgumentException ( 336 "uiComponent referenced by attribute dataScroller@for = '" + 337 forStr + "' must be of type " 338 + UIData.class.getName() + ", not type " + 339 forComp.getClass().getName()); 340 } 341 return (UIData) forComp; 342 } 343 344 347 public void setFirst(UIComponent first) { 348 getFacets().put(FIRST_FACET_NAME, first); 349 } 350 351 355 public UIComponent getFirst() { 356 return (UIComponent) getFacets().get(FIRST_FACET_NAME); 357 } 358 359 362 public void setLast(UIComponent last) { 363 getFacets().put(LAST_FACET_NAME, last); 364 } 365 366 370 public UIComponent getLast() { 371 return (UIComponent) getFacets().get(LAST_FACET_NAME); 372 } 373 374 377 public void setNext(UIComponent next) { 378 getFacets().put(NEXT_FACET_NAME, next); 379 } 380 381 385 public UIComponent getNext() { 386 return (UIComponent) getFacets().get(NEXT_FACET_NAME); 387 } 388 389 393 public void setFastForward(UIComponent previous) { 394 getFacets().put(FAST_FORWARD_FACET_NAME, previous); 395 } 396 397 401 public UIComponent getFastForward() { 402 return (UIComponent) getFacets().get(FAST_FORWARD_FACET_NAME); 403 } 404 405 409 public void setFastRewind(UIComponent previous) { 410 getFacets().put(FAST_REWIND_FACET_NAME, previous); 411 } 412 413 417 public UIComponent getFastRewind() { 418 return (UIComponent) getFacets().get(FAST_REWIND_FACET_NAME); 419 } 420 421 425 public void setPrevious(UIComponent previous) { 426 getFacets().put(PREVIOUS_FACET_NAME, previous); 427 } 428 429 433 public UIComponent getPrevious() { 434 return (UIComponent) getFacets().get(PREVIOUS_FACET_NAME); 435 } 436 437 441 public boolean getRendersChildren() { 442 return true; 443 } 444 445 448 public MethodBinding getAction() { 449 return null; 451 } 452 453 456 public void setAction(MethodBinding action) { 457 throw new UnsupportedOperationException ( 458 "Defining an action is not supported. Use an actionListener"); 459 } 460 461 464 public void setActionListener(MethodBinding actionListener) { 465 _actionListener = actionListener; 466 } 467 468 471 public MethodBinding getActionListener() { 472 return _actionListener; 473 } 474 475 478 public void addActionListener(ActionListener listener) { 479 addFacesListener(listener); 480 } 481 482 485 public ActionListener[] getActionListeners() { 486 return (ActionListener[]) getFacesListeners(ActionListener.class); 487 } 488 489 492 public void removeActionListener(ActionListener listener) { 493 removeFacesListener(listener); 494 } 495 496 public static final String COMPONENT_TYPE = 497 "com.icesoft.faces.DataScroller"; 498 public static final String COMPONENT_FAMILY = "javax.faces.Panel"; 499 private static final String DEFAULT_RENDERER_TYPE = 500 "com.icesoft.faces.DataScroller"; 501 private static final boolean DEFAULT_IMMEDIATE = false; 502 private static final boolean DEFAULT_VERTICAL = false; 503 private String _for = null; 504 private Integer _fastStep = null; 505 private String _pageIndexVar = null; 506 private String _pageCountVar = null; 507 private String _rowsCountVar = null; 508 private String _displayedRowsCountVar = null; 509 private String _firstRowIndexVar = null; 510 private String _lastRowIndexVar = null; 511 private String _style = null; 512 private String _styleClass = null; 513 private String _columnClasses = null; 514 private Boolean _paginator = null; 515 private Integer _paginatorMaxPages = null; 516 private Boolean _renderFacetsIfSinglePage = null; 517 private Boolean _immediate; 518 private Boolean _vertical; 519 public static final String FACET_FIRST = "first".intern(); 520 public static final String FACET_PREVIOUS = "previous".intern(); 521 public static final String FACET_NEXT = "next".intern(); 522 public static final String FACET_LAST = "last".intern(); 523 public static final String FACET_FAST_FORWARD = "fastf".intern(); 524 public static final String FACET_FAST_REWIND = "fastr".intern(); 525 526 public DataPaginator() { 527 setRendererType(DEFAULT_RENDERER_TYPE); 528 } 529 530 533 public String getFamily() { 534 return COMPONENT_FAMILY; 535 } 536 537 540 public void setFor(String forValue) { 541 _for = forValue; 542 } 543 544 547 public String getFor() { 548 if (_for != null) { 549 return _for; 550 } 551 ValueBinding vb = getValueBinding("for"); 552 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 553 } 554 555 558 public void setFastStep(int fastStep) { 559 _fastStep = new Integer (fastStep); 560 } 561 562 565 public int getFastStep() { 566 if (_fastStep != null) { 567 return _fastStep.intValue(); 568 } 569 ValueBinding vb = getValueBinding("fastStep"); 570 Integer v = 571 vb != null ? (Integer ) vb.getValue(getFacesContext()) : null; 572 return v != null ? v.intValue() : Integer.MIN_VALUE; 573 } 574 575 578 public void setPageIndexVar(String pageIndexVar) { 579 _pageIndexVar = pageIndexVar; 580 } 581 582 585 public String getPageIndexVar() { 586 if (_pageIndexVar != null) { 587 return _pageIndexVar; 588 } 589 ValueBinding vb = getValueBinding("pageIndexVar"); 590 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 591 } 592 593 596 public void setPageCountVar(String pageCountVar) { 597 _pageCountVar = pageCountVar; 598 } 599 600 603 public String getPageCountVar() { 604 if (_pageCountVar != null) { 605 return _pageCountVar; 606 } 607 ValueBinding vb = getValueBinding("pageCountVar"); 608 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 609 } 610 611 614 public void setRowsCountVar(String rowsCountVar) { 615 _rowsCountVar = rowsCountVar; 616 } 617 618 621 public String getRowsCountVar() { 622 if (_rowsCountVar != null) { 623 return _rowsCountVar; 624 } 625 ValueBinding vb = getValueBinding("rowsCountVar"); 626 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 627 } 628 629 632 public void setDisplayedRowsCountVar(String displayedRowsCountVar) { 633 _displayedRowsCountVar = displayedRowsCountVar; 634 } 635 636 640 public String getDisplayedRowsCountVar() { 641 if (_displayedRowsCountVar != null) { 642 return _displayedRowsCountVar; 643 } 644 ValueBinding vb = getValueBinding("displayedRowsCountVar"); 645 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 646 } 647 648 651 public void setFirstRowIndexVar(String firstRowIndexVar) { 652 _firstRowIndexVar = firstRowIndexVar; 653 } 654 655 658 public String getFirstRowIndexVar() { 659 if (_firstRowIndexVar != null) { 660 return _firstRowIndexVar; 661 } 662 ValueBinding vb = getValueBinding("firstRowIndexVar"); 663 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 664 } 665 666 669 public void setLastRowIndexVar(String lastRowIndexVar) { 670 _lastRowIndexVar = lastRowIndexVar; 671 } 672 673 676 public String getLastRowIndexVar() { 677 if (_lastRowIndexVar != null) { 678 return _lastRowIndexVar; 679 } 680 ValueBinding vb = getValueBinding("lastRowIndexVar"); 681 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 682 } 683 684 687 public void setStyle(String style) { 688 _style = style; 689 } 690 691 692 695 public String getStyle() { 696 if (_style != null) { 697 return _style; 698 } 699 ValueBinding vb = getValueBinding("style"); 700 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 701 } 702 703 706 public void setStyleClass(String styleClass) { 707 _styleClass = styleClass; 708 } 709 710 713 public String getStyleClass() { 714 return Util.getQualifiedStyleClass(this, 715 _styleClass, 716 CSS_DEFAULT.DATA_PAGINATOR_BASE, 717 "styleClass", 718 isDisabled()); 719 } 720 721 public String getBaseStyleClass() { 722 return CSS_DEFAULT.DATA_PAGINATOR_BASE; 723 } 724 725 728 public void setPaginator(boolean paginator) { 729 _paginator = Boolean.valueOf(paginator); 730 } 731 732 735 public boolean isPaginator() { 736 if (_paginator != null) { 737 return _paginator.booleanValue(); 738 } 739 ValueBinding vb = getValueBinding("paginator"); 740 Boolean v = 741 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 742 return v != null ? v.booleanValue() : false; 743 } 744 745 748 public void setPaginatorMaxPages(int paginatorMaxPages) { 749 _paginatorMaxPages = new Integer (paginatorMaxPages); 750 } 751 752 755 public int getPaginatorMaxPages() { 756 if (_paginatorMaxPages != null) { 757 return _paginatorMaxPages.intValue(); 758 } 759 ValueBinding vb = getValueBinding("paginatorMaxPages"); 760 Integer v = 761 vb != null ? (Integer ) vb.getValue(getFacesContext()) : null; 762 return v != null ? v.intValue() : Integer.MIN_VALUE; 763 } 764 765 766 770 public String getPaginatorTableClass() { 771 return Util.getQualifiedStyleClass(this,CSS_DEFAULT.PAGINATOR_TABLE_CLASS, isDisabled()); 772 773 } 774 775 779 public String getPaginatorColumnClass() { 780 return Util.getQualifiedStyleClass(this,CSS_DEFAULT.PAGINATOR_COLUMN_CLASS, isDisabled()); 781 } 782 783 787 public String getscrollButtonCellClass() { 788 return Util.getQualifiedStyleClass(this,CSS_DEFAULT.DATA_PAGINATOR_SCROLL_BUTTON_CELL_CLASS, isDisabled()); 789 } 790 791 792 796 public String getPaginatorActiveColumnClass() { 797 return Util.getQualifiedStyleClass(this, CSS_DEFAULT.PAGINATOR_ACTIVE_COLUMN_CLASS, isDisabled()); 798 } 799 800 804 public void setRenderFacetsIfSinglePage(boolean renderFacetsIfSinglePage) { 805 _renderFacetsIfSinglePage = Boolean.valueOf(renderFacetsIfSinglePage); 806 } 807 808 812 public boolean isRenderFacetsIfSinglePage() { 813 if (_renderFacetsIfSinglePage != null) { 814 return _renderFacetsIfSinglePage.booleanValue(); 815 } 816 ValueBinding vb = getValueBinding("renderFacetsIfSinglePage"); 817 Boolean v = 818 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 819 return v != null ? v.booleanValue() : true; 820 } 821 822 825 public void setImmediate(boolean immediate) { 826 _immediate = Boolean.valueOf(immediate); 827 } 828 829 832 public boolean isImmediate() { 833 if (_immediate != null) { 834 return _immediate.booleanValue(); 835 } 836 ValueBinding vb = getValueBinding("immediate"); 837 Boolean v = 838 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 839 return v != null ? v.booleanValue() : DEFAULT_IMMEDIATE; 840 } 841 842 845 public void setVertical(boolean vertical) { 846 _vertical = Boolean.valueOf(vertical); 847 } 848 849 852 public boolean isVertical() { 853 if (_vertical != null) { 854 return _vertical.booleanValue(); 855 } 856 ValueBinding vb = getValueBinding("vertical"); 857 Boolean v = 858 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 859 return v != null ? v.booleanValue() : DEFAULT_VERTICAL; 860 } 861 862 865 public boolean isRendered() { 866 if (!Util.isRenderedOnUserRole(this)) { 867 return false; 868 } 869 return super.isRendered(); 870 } 871 872 876 public Object saveState(FacesContext context) { 877 Object values[] = new Object [18]; 878 values[0] = super.saveState(context); 879 values[1] = _for; 880 values[2] = _fastStep; 881 values[3] = _pageIndexVar; 882 values[4] = _pageCountVar; 883 values[5] = _rowsCountVar; 884 values[6] = _displayedRowsCountVar; 885 values[7] = _firstRowIndexVar; 886 values[8] = _lastRowIndexVar; 887 values[9] = _style; 888 values[10] = _styleClass; 889 values[11] = _columnClasses; 890 values[12] = _paginator; 891 values[13] = _paginatorMaxPages; 892 values[14] = _renderFacetsIfSinglePage; 893 values[15] = _immediate; 894 values[16] = saveAttachedState(context, _actionListener); 895 values[17] = _vertical; 896 return values; 897 } 898 899 903 public void restoreState(FacesContext context, Object state) { 904 Object values[] = (Object []) state; 905 super.restoreState(context, values[0]); 906 _for = (String ) values[1]; 907 _fastStep = (Integer ) values[2]; 908 _pageIndexVar = (String ) values[3]; 909 _pageCountVar = (String ) values[4]; 910 _rowsCountVar = (String ) values[5]; 911 _displayedRowsCountVar = (String ) values[6]; 912 _firstRowIndexVar = (String ) values[7]; 913 _lastRowIndexVar = (String ) values[8]; 914 _style = (String ) values[9]; 915 _styleClass = (String ) values[10]; 916 _columnClasses = (String ) values[11]; 917 _paginator = (Boolean ) values[12]; 918 _paginatorMaxPages = (Integer ) values[13]; 919 _renderFacetsIfSinglePage = (Boolean ) values[14]; 920 _immediate = (Boolean ) values[15]; 921 _actionListener = 922 (MethodBinding) restoreAttachedState(context, values[16]); 923 _vertical = (Boolean ) values[17]; 924 } 925 926 929 public void gotoFirstPage() { 930 getUIData().setFirst(0); 931 } 932 933 936 public void gotoPreviousPage() { 937 if (isModelResultSet()) { 938 int first = getUIData().getFirst() - getUIData().getRows(); 939 if (first < 0) { 940 first = 0; 941 } 942 getUIData().setFirst(first); 943 } else { 944 int previous = getUIData().getFirst() - getUIData().getRows(); 945 int rowCount = getRowCount(); 946 if (previous >= 0) { 947 if (previous > rowCount) { 948 previous = rowCount; 949 } 950 getUIData().setFirst(previous); 951 } 952 } 953 } 954 955 958 public void gotoNextPage() { 959 int next = getUIData().getFirst() + getUIData().getRows(); 960 if (isModelResultSet()) { 961 getUIData().setRowIndex(next); 962 if (getUIData().isRowAvailable()) { 963 getUIData().setFirst(next); 964 } 965 } else { 966 if (next < getUIData().getRowCount()) { 967 getUIData().setFirst(next); 968 } 969 } 970 } 971 972 976 public void gotoFastForward() { 977 int fastStep = getFastStep(); 978 if (fastStep <= 0) { 979 fastStep = 1; 980 } 981 int next = getUIData().getFirst() + getUIData().getRows() * fastStep; 982 int rowcount = getUIData().getRowCount(); 983 if (next >= rowcount) { 984 next = (rowcount - 1) - ((rowcount - 1) % getUIData().getRows()); 985 } 986 getUIData().setFirst(next); 987 } 988 989 993 public void gotoFastRewind() { 994 int fastStep = getFastStep(); 995 if (fastStep <= 0) { 996 fastStep = 1; 997 } 998 int previous = 999 getUIData().getFirst() - getUIData().getRows() * fastStep; 1000 if (previous < 0) { 1001 previous = 0; 1002 } 1003 getUIData().setFirst(previous); 1004 } 1005 1006 1009 public void gotoLastPage() { 1010 if (isModelResultSet()) { 1011 int first = getUIData().getFirst(); 1012 while (true) { 1013 getUIData().setRowIndex(first + 1); 1014 if (getUIData().isRowAvailable()) { 1015 first++; 1016 } else { 1017 break; 1018 } 1019 } 1020 getUIData().setFirst(first - (first % getUIData().getRows())); 1021 } else { 1022 int rowcount = getUIData().getRowCount(); 1023 int rows = getUIData().getRows(); 1024 int delta = rowcount % rows; 1025 int first = delta > 0 && delta < rows ? rowcount - delta : 1026 rowcount - rows; 1027 if (first >= 0) { 1028 getUIData().setFirst(first); 1029 } else { 1030 getUIData().setFirst(0); 1031 } 1032 } 1033 } 1034 1035 1038 public boolean isLastPage() { 1039 return (getPageIndex() >= getPageCount()) ? true : false; 1040 } 1041 1042 private String enabledOnUserRole = null; 1043 private String renderedOnUserRole = null; 1044 1045 1048 public void setEnabledOnUserRole(String enabledOnUserRole) { 1049 this.enabledOnUserRole = enabledOnUserRole; 1050 } 1051 1052 1055 public String getEnabledOnUserRole() { 1056 if (enabledOnUserRole != null) { 1057 return enabledOnUserRole; 1058 } 1059 ValueBinding vb = getValueBinding("enabledOnUserRole"); 1060 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 1061 } 1062 1063 1066 public void setRenderedOnUserRole(String renderedOnUserRole) { 1067 this.renderedOnUserRole = renderedOnUserRole; 1068 } 1069 1070 1073 public String getRenderedOnUserRole() { 1074 if (renderedOnUserRole != null) { 1075 return renderedOnUserRole; 1076 } 1077 ValueBinding vb = getValueBinding("renderedOnUserRole"); 1078 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 1079 } 1080 1081 private Boolean modelResultSet = null; 1082 1083 public boolean isModelResultSet() { 1084 1085 if (modelResultSet == null) { 1086 if (getUIData().getValue() instanceof ResultSet ) { 1087 modelResultSet = Boolean.TRUE; 1088 } else { 1089 if (getUIData() 1090 .getValue() instanceof javax.faces.model.DataModel) { 1091 javax.faces.model.DataModel dataModel = 1092 (javax.faces.model.DataModel) getUIData() 1093 .getValue(); 1094 if (dataModel.getRowCount() == -1) { 1095 modelResultSet = Boolean.TRUE; 1096 return modelResultSet.booleanValue(); 1097 } 1098 } 1099 modelResultSet = Boolean.FALSE; 1100 } 1101 } 1102 return modelResultSet.booleanValue(); 1103 } 1104} 1105 | Popular Tags |