01: /*
02: * Created on Apr 5, 2004
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: //** Copyright Statement ***************************************************
08: //The Salmon Open Framework for Internet Applications (SOFIA)
09: //Copyright (C) 1999 - 2002, Salmon LLC
10: //
11: //This program is free software; you can redistribute it and/or
12: //modify it under the terms of the GNU General Public License version 2
13: //as published by the Free Software Foundation;
14: //
15: //This program is distributed in the hope that it will be useful,
16: //but WITHOUT ANY WARRANTY; without even the implied warranty of
17: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: //GNU General Public License for more details.
19: //
20: //You should have received a copy of the GNU General Public License
21: //along with this program; if not, write to the Free Software
22: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23: //
24: //For more information please visit http://www.salmonllc.com
25: //** End Copyright Statement ***************************************************
26: package com.salmonllc.html;
27:
28: import com.salmonllc.properties.Props;
29:
30: /**
31: * A renderer for the Page Selector for JSPDataTable, HtmlDataTable, HtmlDataTable2D and JspList, that renders as underline links
32: */
33: public class DataTablePageSelectRendererLink extends
34: DataTablePageSelectRenderer {
35: protected String _font = Props.FONT_BUTTON;
36:
37: public String generateRowSelector(HtmlComponent comp, String theme,
38: String pageLabel, String pageOfLabel, int page,
39: int firstSubmitButton, int noButtons, int maxPagingButtons,
40: String imageURL) {
41: Props pr = comp.getPage().getPageProperties();
42: String fontStart = pr.getThemeProperty(theme, Props.FONT_BUTTON
43: + Props.TAG_START);
44: String fontEnd = pr.getThemeProperty(theme, Props.FONT_BUTTON
45: + Props.TAG_END);
46: if (fontStart == null) {
47: fontStart = "";
48: fontEnd = "";
49: }
50: String linkStart = pr.getThemeProperty(theme, Props.FONT_LINK
51: + Props.TAG_START);
52: String linkEnd = pr.getThemeProperty(theme, Props.FONT_LINK
53: + Props.TAG_END);
54: StringBuffer sb = new StringBuffer();
55:
56: sb.append(fontStart + pageLabel + ": " + page + " "
57: + pageOfLabel + " " + noButtons + " ");
58: genLinkJavascript(comp, sb);
59:
60: if (noButtons > maxPagingButtons && firstSubmitButton > 0) {
61: if (noButtons > 2)
62: sb.append("<A HREF=\"javascript:" + comp.getFullName()
63: + "_selectPage('first');\">" + linkStart
64: + "<<" + linkEnd + "</A> "); //FIRST
65: sb.append("<A HREF=\"javascript:" + comp.getFullName()
66: + "_selectPage('prior');\">" + linkStart + "<"
67: + linkEnd + "</A> "); //PRIOR
68: }
69: for (int i = 0; (i < noButtons) && (i < maxPagingButtons); i++) {
70: int button = i + firstSubmitButton + 1;
71: if (button == page)
72: sb.append(linkStart + button + linkEnd + " ");
73: else
74: sb.append("<A HREF=\"javascript:" + comp.getFullName()
75: + "_selectPage('" + (i + firstSubmitButton)
76: + "');\">" + linkStart
77: + (i + firstSubmitButton + 1) + linkEnd
78: + "</A> ");
79: }
80: if ((firstSubmitButton + (maxPagingButtons == 0 ? 1
81: : maxPagingButtons)) < noButtons) {
82: sb.append("<A HREF=\"javascript:" + comp.getFullName()
83: + "_selectPage('next');\">" + linkStart + ">"
84: + linkEnd + "</A> ");
85: if (noButtons > 2)
86: sb.append("<A HREF=\"javascript:" + comp.getFullName()
87: + "_selectPage('last');\">" + linkStart
88: + ">>" + linkEnd + "</A> ");
89: }
90: sb.append(fontEnd);
91: return sb.toString();
92: }
93: }
|