Source Code Cross Referenced for TablePagination.java in  » Portal » Open-Portal » com » sun » portal » iwayutil » sorting » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.iwayutil.sorting 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions
006:         * are met:
007:         *
008:         * - Redistributions of source code must retain the above copyright
009:         *   notice, this list of conditions and the following disclaimer.
010:         *
011:         * - Redistribution in binary form must reproduce the above copyright
012:         *   notice, this list of conditions and the following disclaimer in
013:         *   the documentation and/or other materials provided with the
014:         *   distribution.
015:         *
016:         * Neither the name of Sun Microsystems, Inc. or the names of
017:         * contributors may be used to endorse or promote products derived
018:         * from this software without specific prior written permission.
019:         *
020:         * This software is provided "AS IS," without a warranty of any
021:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024:         * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026:         * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027:         * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028:         * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029:         * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030:         * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031:         * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032:         *
033:         * You acknowledge that Software is not designed, licensed or intended
034:         * for use in the design, construction, operation or maintenance of
035:         * any nuclear facility.
036:         */
037:        package com.sun.portal.iwayutil.sorting;
038:
039:        /**
040:         *
041:         * This class provides the utility methods sort the table data
042:         *
043:         * @version 1.0
044:         * @author Deepak H P
045:         * @date 02 May 2005
046:         *
047:         **/
048:
049:        import java.util.*;
050:        import javax.portlet.*;
051:
052:        public class TablePagination {
053:
054:            public static void setPaginationRow(RenderRequest request,
055:                    RenderResponse response, String paginationType,
056:                    String query, int size) {
057:
058:                StringBuffer pagRowBuf = new StringBuffer();
059:                String tableImagesLocation = response.encodeURL(request
060:                        .getContextPath())
061:                        + "/images/table/";
062:                String imgPagFirst = tableImagesLocation
063:                        + "pagination_first.gif";
064:                String imgPagLast = tableImagesLocation + "pagination_last.gif";
065:                String imgPagNext = tableImagesLocation + "pagination_next.gif";
066:                String imgPagPrev = tableImagesLocation + "pagination_prev.gif";
067:                String imgPagDot = tableImagesLocation + "dot.gif";
068:                String curPageStr = (String) request
069:                        .getAttribute("CurrentPage");
070:                String curSumPageStr = (String) request
071:                        .getAttribute("CurrentSummaryPage");
072:
073:                String actionURL = response.createActionURL().toString();
074:                String firstActionURL = null;
075:                String lastActionURL = null;
076:                String prevActionURL = null;
077:                String nextActionURL = null;
078:
079:                String firstPageTitle = null;
080:                String prevPageTitle = null;
081:                String nextPageTitle = null;
082:                String lastPageTitle = null;
083:                String pageTitle = null;
084:                String ofTitle = null;
085:                String goButtonTitle = null;
086:
087:                int firstPage = 0;
088:                int lastPage = 0;
089:                int prevPage = 0;
090:                int nextPage = 0;
091:                int curPage = 0;
092:                int curSumPage = 0;
093:
094:                try {
095:                    ResourceBundle rb = ResourceBundle
096:                            .getBundle("IWayUtilMessages");
097:                    firstPageTitle = rb.getString("GO_TO_FIRST_PAGE_TITLE");
098:                    prevPageTitle = rb.getString("GO_TO_PREV_PAGE_TITLE");
099:                    nextPageTitle = rb.getString("GO_TO_NEXT_PAGE_TITLE");
100:                    lastPageTitle = rb.getString("GO_TO_LAST_PAGE_TITLE");
101:                    pageTitle = rb.getString("PAGE_TITLE");
102:                    ofTitle = rb.getString("OF_TITLE");
103:                    goButtonTitle = rb.getString("GO_BUTTON_TITLE");
104:                } catch (Exception ex) {
105:                    firstPageTitle = "Go to First Page";
106:                    prevPageTitle = "Go to Previous Page";
107:                    nextPageTitle = "Go to Next Page";
108:                    lastPageTitle = "Go to Last Page";
109:                    pageTitle = "Page";
110:                    ofTitle = "of";
111:                    goButtonTitle = "GO";
112:                }
113:                debug("curPageStr : " + curPageStr + " curSumPageStr :  "
114:                        + curSumPageStr);
115:
116:                try {
117:                    curSumPage = Integer.parseInt(curSumPageStr);
118:                    if (curSumPage < 1) {
119:                        curSumPageStr = "1";
120:                    }
121:                } catch (Exception ex) {
122:                    curSumPageStr = "1";
123:                }
124:
125:                try {
126:                    curPage = Integer.parseInt(curPageStr);
127:                } catch (Exception ex) {
128:
129:                    if (size > 0) {
130:                        curPage = 1;
131:                    } else {
132:                        curPage = 0;
133:                    }
134:                }
135:
136:                debug("RowData Size: " + size);
137:
138:                if (size > 0) {
139:                    firstPage = 1;
140:                    lastPage = size;
141:
142:                    if (curPage < lastPage) {
143:                        nextPage = curPage + 1;
144:                    } else {
145:                        nextPage = lastPage;
146:                    }
147:
148:                    if (curPage > firstPage) {
149:                        prevPage = curPage - 1;
150:                    } else {
151:                        prevPage = firstPage;
152:                    }
153:                }
154:
155:                firstActionURL = actionURL + "&PaginationType="
156:                        + paginationType + "&CurrentSummaryPage="
157:                        + curSumPageStr
158:                        + "&RequestType=Paginate&QueryField=first&QueryValue="
159:                        + firstPage;
160:                lastActionURL = actionURL + "&PaginationType=" + paginationType
161:                        + "&CurrentSummaryPage=" + curSumPageStr
162:                        + "&RequestType=Paginate&QueryField=last&QueryValue="
163:                        + lastPage;
164:                prevActionURL = actionURL + "&PaginationType=" + paginationType
165:                        + "&CurrentSummaryPage=" + curSumPageStr
166:                        + "&RequestType=Paginate&QueryField=prev&QueryValue="
167:                        + prevPage;
168:                nextActionURL = actionURL + "&PaginationType=" + paginationType
169:                        + "&CurrentSummaryPage=" + curSumPageStr
170:                        + "&RequestType=Paginate&QueryField=next&QueryValue="
171:                        + nextPage;
172:
173:                if (query != null) {
174:                    String cQuery = "&CurrentQuery=" + query;
175:                    firstActionURL = firstActionURL + cQuery;
176:                    lastActionURL = lastActionURL + cQuery;
177:                    prevActionURL = prevActionURL + cQuery;
178:                    nextActionURL = nextActionURL + cQuery;
179:                }
180:
181:                if (curPage == firstPage) {
182:                    imgPagFirst = tableImagesLocation
183:                            + "pagination_first_dis.gif";
184:                    imgPagPrev = tableImagesLocation
185:                            + "pagination_prev_dis.gif";
186:                    firstActionURL = "#";
187:                    prevActionURL = "#";
188:                }
189:
190:                if (curPage == lastPage) {
191:                    imgPagLast = tableImagesLocation
192:                            + "pagination_last_dis.gif";
193:                    imgPagNext = tableImagesLocation
194:                            + "pagination_next_dis.gif";
195:                    nextActionURL = "#";
196:                    lastActionURL = "#";
197:                }
198:                debug("curPage : " + curPage + "  fPage : " + firstPage
199:                        + "  lPage : " + lastPage);
200:                pagRowBuf.append("<form action='");
201:                pagRowBuf.append(actionURL);
202:                pagRowBuf.append("' method=post>");
203:                pagRowBuf.append("<tr>");
204:                pagRowBuf
205:                        .append("<td class=\"TblActTdLst\" colspan=\"5\" nowrap=\"nowrap\">");
206:                pagRowBuf.append("<a href=" + "\"" + firstActionURL + "\""
207:                        + " title=\"" + firstPageTitle + "\">");
208:                pagRowBuf
209:                        .append("<img src="
210:                                + imgPagFirst
211:                                + " alt=\""
212:                                + firstPageTitle
213:                                + "\" align=\"top\" border=\"0\" height=\"20\" width=\"23\">");
214:                pagRowBuf.append("</a>");
215:                pagRowBuf.append("<a href=" + "\"" + prevActionURL + "\""
216:                        + " title=\"" + prevPageTitle + "\">");
217:                pagRowBuf
218:                        .append("<img src="
219:                                + imgPagPrev
220:                                + " alt=\""
221:                                + prevPageTitle
222:                                + "\" align=\"top\" border=\"0\" height=\"20\" width=\"23\">");
223:                pagRowBuf.append("</a>");
224:                pagRowBuf.append("<img src=" + imgPagDot
225:                        + " alt=\"\" height=\"1\" width=\"10\">");
226:                pagRowBuf
227:                        .append("<span class=\"LblLev2Txt\"> <label for=\"pagenumfield\">"
228:                                + pageTitle + ":&nbsp;</label> </span>");
229:
230:                pagRowBuf
231:                        .append("<input type='hidden' name='RequestType' value='Paginate'>");
232:                pagRowBuf
233:                        .append("<input type='hidden' name='PaginationType' value='");
234:                pagRowBuf.append(paginationType);
235:                pagRowBuf.append("'>");
236:                pagRowBuf
237:                        .append("<input type='hidden' name='TableSize' value='");
238:                pagRowBuf.append(size);
239:                pagRowBuf.append("'>");
240:                pagRowBuf
241:                        .append("<input type='hidden' name='CurrentSummaryPage' value='");
242:                pagRowBuf.append(curSumPageStr);
243:                pagRowBuf.append("'>");
244:                pagRowBuf
245:                        .append("<input type='hidden' name='QueryField' value='goTo'>");
246:
247:                if (query != null) {
248:                    pagRowBuf
249:                            .append("<input type='hidden' name='CurrentQuery' value=\""
250:                                    + query + "\">");
251:                }
252:                pagRowBuf
253:                        .append("<input name='QueryValue' class=\"TxtFld\" value="
254:                                + curPage + " size=\"3\" type=\"text\"> &nbsp;");
255:                pagRowBuf.append("<span class=\"TblPgnTxt\">" + ofTitle + " "
256:                        + size + "&nbsp;&nbsp;</span>");
257:                pagRowBuf
258:                        .append("<input class=\"Btn1\" type=\"submit\" name=\"goButton\" value=\""
259:                                + goButtonTitle + "\" />");
260:                pagRowBuf.append("<img src=" + imgPagDot
261:                        + " alt=\"\" height=\"1\" width=\"10\">");
262:                pagRowBuf.append("<a href=" + "\"" + nextActionURL + "\""
263:                        + " title=\"" + nextPageTitle + "\">");
264:                pagRowBuf
265:                        .append("<img src="
266:                                + imgPagNext
267:                                + " alt=\""
268:                                + nextPageTitle
269:                                + "\" align=\"top\" border=\"0\" height=\"20\" width=\"23\">");
270:                pagRowBuf.append("</a>");
271:                pagRowBuf.append("<a href=" + "\"" + lastActionURL + "\""
272:                        + " title=\"" + lastPageTitle + "\">");
273:                pagRowBuf
274:                        .append("<img src="
275:                                + imgPagLast
276:                                + " alt=\""
277:                                + lastPageTitle
278:                                + "\" align=\"top\" border=\"0\" height=\"20\" width=\"23\">");
279:                pagRowBuf.append("</a>");
280:                pagRowBuf.append("<img src=" + imgPagDot
281:                        + " alt=\"\" height=\"1\" width=\"10\">");
282:                pagRowBuf.append("</td>");
283:                pagRowBuf.append("</tr>");
284:                pagRowBuf.append("</form>");
285:
286:                String pagRowStr = pagRowBuf.toString();
287:                request.setAttribute("PaginationRow", pagRowStr);
288:
289:            }
290:
291:            /**
292:             * This method will print the debug messages.
293:             **/
294:            private static void debug(Object msg) {
295:                System.out.println("TablePagination : " + msg);
296:            }
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.