1 5 6 package com.raptus.owxv3.api; 7 8 import java.util.*; 9 10 import javax.servlet.http.HttpServletRequest ; 11 12 import org.apache.struts.action.ActionMapping; 13 14 import com.raptus.owxv3.LoggingManager; 15 16 39 public class PagedListBean extends OmniaWebBean 40 { 41 44 protected Vector list = null; 45 46 49 protected int offset = 0; 50 51 54 protected int maxRows = 0; 55 56 59 protected int currentPage = 1; 60 61 64 protected String uri = null; 65 66 69 protected String vmodule=null; 70 71 74 public void updatePage() 75 { 76 if(list != null && maxRows > 0) 77 { 78 offset = ((currentPage * maxRows) - maxRows); 79 if(offset >= list.size()) 80 offset = 0; 81 } 82 else 83 offset = 0; 84 85 } 87 88 91 public int getPageCount() 92 { 93 float count = 0; 94 if(list != null) 95 { 96 if(maxRows > 0) 97 count = ((float) (list.size())) / ((float) maxRows); 98 else 99 count = 1; 100 if( count > ((float) ((int) count)) ) 102 count ++; 103 } 104 105 return (int) count; 106 } 107 108 111 public void setCurrentPage(int pageNo) 112 { 113 if( (pageNo > 0) && (pageNo <= getPageCount()) ) 114 currentPage = pageNo; 115 else 116 currentPage = 1; 117 118 updatePage(); 119 } 120 121 124 public boolean isListLoaded(Locale l,String vmid) 125 { 126 return (list != null && (currLocale != null && currLocale.equals(l)) && (vmodule!=null && vmodule.equals(vmid)) ); 127 } 128 129 132 public void setList(Vector list, Locale lcle,String vmid) 133 { 134 this.list = list; 135 this.currLocale = lcle; 136 this.vmodule=vmid; 137 updatePage(); 138 } 139 140 143 public Vector getList() { return list; } 144 145 148 public int getMaxRows() { return maxRows; } 149 public void setMaxRows(int rows) { this.maxRows = rows; } 150 151 154 public int getOffset() { return offset; } 155 156 159 public int getCurrentPage() { return currentPage; } 160 161 164 public String getURI() { return uri; } 165 166 169 public void setURI(String uri) { this.uri = uri; } 170 171 174 public void reset(ActionMapping mapping, HttpServletRequest request) 175 { 176 178 super.reset(mapping, request); 179 } 180 181 } 182 183 | Popular Tags |