01: //** Copyright Statement ***************************************************
02: //The Salmon Open Framework for Internet Applications (SOFIA)
03: // Copyright (C) 1999 - 2002, Salmon LLC
04: //
05: // This program is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU General Public License version 2
07: // as published by the Free Software Foundation;
08: //
09: // This program is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: // GNU General Public License for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // along with this program; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: //
18: // For more information please visit http://www.salmonllc.com
19: //** End Copyright Statement ***************************************************
20: package com.salmonllc.html;
21:
22: import com.salmonllc.properties.Props;
23:
24: /**
25: * The default render for data table rows per page bar
26: *
27: */
28: public class DataTableRowsPerPageRendererDefault extends
29: DataTableRowsPerPageRenderer {
30: protected String _font = Props.FONT_BUTTON;
31:
32: public String generateRowSelector(HtmlComponent comp, String theme,
33: String totalRowsLabel, String rowsPerPageLabel,
34: String summaryRowText, int rowsPerPage, int rowCount) {
35: Props pr = comp.getPage().getPageProperties();
36: String fontStart = pr.getThemeProperty(theme, _font
37: + Props.TAG_START);
38: String fontEnd = pr.getThemeProperty(theme, _font
39: + Props.TAG_END);
40: if (fontStart == null) {
41: fontStart = "";
42: fontEnd = "";
43: }
44: StringBuffer sb = new StringBuffer();
45: sb.append("<INPUT TYPE=\"HIDDEN\" name=\"" + comp.getFullName()
46: + "_rows_per_page_hidden\" value=\"-1\">");
47: sb.append("<SCRIPT>");
48: sb.append("function " + comp.getFullName()
49: + "_setRowsPerPage(rpp) {");
50: sb.append(comp.getFormString() + comp.getFullName()
51: + "_rows_per_page_hidden.value = rpp;");
52: sb.append(comp.getFormString() + "submit();");
53: sb.append("}");
54: sb.append("</SCRIPT>");
55: sb.append(fontStart);
56: sb.append(totalRowsLabel + ": " + rowCount
57: + " ");
58: sb.append(rowsPerPageLabel + ": ");
59: sb.append("<SELECT name=\"" + comp.getFullName()
60: + "row_per_page_dd\" onChange=\"javascript:"
61: + comp.getFullName()
62: + "_setRowsPerPage(options[selectedIndex].text);\">");
63: if (rowsPerPage != 10 && rowsPerPage != 20 && rowsPerPage != 50
64: && rowsPerPage != 100 && rowsPerPage != 500
65: && rowsPerPage != 1000)
66: sb.append("<OPTION SELECTED>" + rowsPerPage);
67: sb.append("<OPTION" + (rowsPerPage == 10 ? " SELECTED" : "")
68: + "> 10");
69: sb.append("<OPTION" + (rowsPerPage == 20 ? " SELECTED" : "")
70: + "> 20");
71: sb.append("<OPTION" + (rowsPerPage == 50 ? " SELECTED" : "")
72: + "> 50");
73: sb.append("<OPTION" + (rowsPerPage == 100 ? " SELECTED" : "")
74: + "> 100");
75: sb.append("<OPTION" + (rowsPerPage == 500 ? " SELECTED" : "")
76: + "> 500");
77: sb.append("<OPTION" + (rowsPerPage == 1000 ? " SELECTED" : "")
78: + "> 1000");
79: sb.append("</SELECT>");
80: sb.append(summaryRowText == null ? ""
81: : " " + summaryRowText);
82: sb.append(fontEnd);
83: return sb.toString();
84: }
85: }
|